Here is the Create code and the Constructor:
NS_METHOD CJavaPluginFactory::Create(nsISupports* outer,
const nsIID& aIID,
void* *aInstancePtr) {
nsresult rv = NS_ERROR_UNEXPECTED;
CJavaPluginFactory * f = NULL;
fprintf(stderr,"In the Create function!!!!\n");
f = new CJavaPluginFactory(&g_App,NULL);
if(f != NULL) {
rv = f->QueryInterface(aIID,aInstancePtr);
if(NS_FAILED(rv)) {
rv = f->CreateInstance(outer,aIID,aInstancePtr);
}
}
return rv;
}
CJavaPluginFactory::CJavaPluginFactory(CJavaPluginApp* app, nsISupports*
pProvider)
: m_app(app), mProvider(NULL)
{
TRACE("CJavaPluginFactory::CJavaPluginFactory\n");
NS_INIT_REFCNT();
m_szClassPath[0] = '\0';
m_pIJVMConsole = NULL;
m_pIJavaVM = m_app->GetIJavaVM();
// Create Aggregated object for nsIJVMConsole.
CJavaConsole::Create((nsIJVMPlugin*)this, m_pIJavaVM, kISupportsIID,
(void**)&m_pIJVMConsole);
mProvider = new CPluginServiceProvider(pProvider);
mProvider->AddRef();
}
I'm not sure why calling the Constructor from the Create code should be odd.
Isn't that what the Create funtion is for?
As for the QueryInterface in the Constructor, I aggree that that is odd but that
code block is there becuase my experience with doing this on UNIX was that
mozilla/netscape would use the Create code to Create both the Factory and the
things that the factory was suppose to Create.
In other words, Mozilla would call Create when it wanted a Factory AND it would
call Create when it wanted a plugin instance. I didn't expect it to work this
way, but that is what happens on UNIX.
We don't do anything with aOuter, we are not aggregated. Should we be?
Thanks,
Steve Katz
In article <[EMAIL PROTECTED]>, Rick Parrish says...
>
>Steven Katz wrote:
>
>> I can't seem to get a handle on what is causing the problem below.
>>
>> In particular, why should the AddRef in the running mozilla case belong to
>> nsBinaryInputStream? I have stepped through the debugger and found that
>> QueryInterface and Release for this same object don't refer back to
>> nsBinaryInputStream, but to nsServiceManagerImpl as you would expect. How can
>> this be?
>>
>> Could someone help me out here? Is it possible I am linking my plugin
>> incorrectly? I am currently linking it against the xpcom.lib. Is there
>> something else I need to do?
>>
>> Steve Katz
>
>
>Hi Steven,
>
>The last stack track you posted showed the code blowing up
>somewhere inside the CJavaPluginFactory constructor. I can't
>see the code so I don't know whats going on here.
>
>One thing that seemed odd is your CJavaPluginFactory::Create
>method called the new operator thereby calling the CJavaPluginFactory
>constructor. It then did a QI and if that failed called
>CJavaPluginFactory::CreateInstance().
>
>What is the CreateInstance() method doing in this case?
>
>Also, I don't see where you are storing the |outer| pointer. Does
>your plug-in need to support aggregation?
>
>-rick
>