if you provide a simplified testcase that builds, i can help you debug.

-darin



steve lu wrote:
Hi,
 
I have read all the previous threads on nsIWebProgressListener.
I have included the Interface of nsISupportsWeakReference, nsIObserver, and nsIWebProgressListener.
I have put AddProgressListener into the Observe() routine upon "xpcom-startup".
 
still, the xpcom object crashes inside of AddProgressListener() with error msg saying "pure virtual function".
 
My code set up is as follows:
(1) Gecko SDK 1.7.3 with xpcomglue.lib and xpcom.lib linked in
(2) Test with Mozilla 1.7.3 and Firfox 0.9x
 
----------------------------------------------------------------------------------------------------------
Here is what is inside of my observe() code:
 
if (strcmp(aTopic, "xpcom-startup") == 0)
 {
  nsCOMPtr<nsIServiceManager> servMan;
  nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
  if (NS_FAILED(rv))
   return NS_OK;
 
  nsCOMPtr<nsIWebProgress> progress;
  rv = servMan->GetServiceByContractID( "@mozilla.org/docloaderservice;1",
         NS_GET_IID(nsIWebProgress),
         getter_AddRefs(progress));
 
  if (NS_SUCCEEDED(rv))
  {   
   if (progress)
    progress->AddProgressListener(NS_STATIC_CAST(nsIWebProgressListener*,this),
         nsIWebProgress::NOTIFY_STATE_DOCUMENT);
  }
 }
----------------------------------------------------------------------------------------------------------
I have provided the impl for 4 interfaces
 
NS_IMPL_ISUPPORTS4(MyComponent,
       IMyComponent,
       nsIWebProgressListener,
                   nsIObserver,
                   nsISupportsWeakReference)
 
----------------------------------------------------------------------------------------------------------
 
Here is the MyComponentRegistration code:
 
nsresult rv;
 nsCOMPtr<nsIServiceManager> servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
 
 if (NS_FAILED(rv))
  return rv;
 
 nsCOMPtr<nsICategoryManager> catman;
 rv = servman->GetServiceByContractID( NS_CATEGORYMANAGER_CONTRACTID,
         NS_GET_IID(nsICategoryManager),
         getter_AddRefs(catman));
 
 if (NS_FAILED(rv))
  return rv;
 

 char *previous = nsnull;
 rv = catman->AddCategoryEntry("xpcom-startup",
       MY_COMPONENT_CLASSNAME,
       MY_COMPONENT_CONTRACTID,
       PR_TRUE,
       PR_TRUE,
       &previous);
 
 if (NS_FAILED(rv))
  return rv;
 
 if (previous)
  nsMemory::Free(previous);
 
 return rv;
 
----------------------------------------------------------------------------------------------------------
 
Any help is appreciated
 
Thanks,
 
Steve Lu

_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to