Re: simple nsIWebProgressListener question

[email protected] (yueweng)
Newsgroups gmane.comp.mozilla.devel.xpinstall
Organization http://groups.google.com
Message-ID <[email protected]>
> However, why not just use:
> NS_IMPL_ISUPPORTS4(nsSampleImpl, nsIWebProgressListener,
> nsISupportsWeakReference, nsIObserver, nsISample)
> 
> (if you do that, you have to remove NS_IMPL_ADDREF and NS_IMPL_RELEASE)
> 
> 
> --
Hi Christian,

Thanks for your quick response.

After implementing NS_IMPL_ISUPPORTS4(nsSampleImpl,
nsIWebProgressListener,
 nsISupportsWeakReference, nsIObserver, nsISample), things seem to be
better.

However, now, my program crashed at the macro
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleImpl) ==
nsSampleImplConstructor().  nsSampleImplConstructor() functionis is
listed under nsModule ComponentInfo components[].  The exact point
that crashed inside nsSampleImplConstructor() is inst->AddRef().

inst seems to carry invalid information:

-	inst	0x009dbe90
+	nsIWebProgressListener	{...}
-	nsSupportsWeakReference	{...}
-	nsISupportsWeakReference	{...}
-	nsISupports	{...}
-	__vfptr	0xfeeefeee
	[0]	CXX0030: Error: expression cannot be evaluated
	[1]	CXX0030: Error: expression cannot be evaluated
	[2]	CXX0030: Error: expression cannot be evaluated
+	mProxy	0xfeeefeee
+	nsIObserver	{...}
-	nsISample	{...}
-	nsISupports	{...}
-	__vfptr	0xfeeefeee
	[0]	CXX0030: Error: expression cannot be evaluated
	[1]	CXX0030: Error: expression cannot be evaluated
	[2]	CXX0030: Error: expression cannot be evaluated
+	mRefCnt	{...}
+	_mOwningThread	{...}
+	mValue	0xfeeefeee ""

The callstack is as follows:

nsSampleImplConstructor() line 99
nsGenericFactory::CreateInstance() line 82 + 21 bytes
nsComponentManagerImpl::CreateInstanceByContractID() line 2000 + 24
bytes
nsComponentManagerImpl::GetServiceByContractID() line 2420 + 50 bytes
nsGetServiceByContractID::operator()() line 121 + 38 bytes
nsCOMPtr_base::assign_from_helper() line 114 + 18 bytes
nsCOMPtr<nsISupports>::nsCOMPtr<nsISupports>() line 846
NS_CreateServicesFromCategory() line 785 + 37 bytes
NS_InitXPCOM2() line 633 + 17 bytes
NS_InitXPCOM2() line 173 + 18 bytes
GRE_Startup() line 477 + 35 bytes
main() line 1705 + 5 bytes
mainCRTStartup() line 338 + 17 bytes
KERNEL32! 77e814c7()

I realised that nsSampleImpl and ~nsSampleImpl are called once before
the crashed occurs:

nsSampleImpl() enter.
~nsSampleImpl() enter
~nsSampleImpl() exit.
nsSampleImpl() exit.
-------------------
crashed occurs
-------------------

I am wonder if you know what's went wrong, please help me if you got
any idea.

Thanks,
YueWeng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.