зеркало из https://github.com/mozilla/pjs.git
a=edburns
r=ashuk bugs: 44327, 44328 NativeEventThread: Re-instate the policy of creating an EventQueue for each window. Put in a superfluous printf in processEventLoop that fixes 44327. nsActions.{cpp,h}: Added wsDeallocateInitContextEvent, to enable the correct removal of the eventQueue, 44328 WindowControlImpl Fire the wsDeallocateInitcontextEvent in nativeDestroyInitContext.
This commit is contained in:
Родитель
b4e20ad332
Коммит
41198b5da0
|
@ -149,8 +149,6 @@ nsresult InitMozillaStuff (WebShellInitContext * arg);
|
||||||
nsISHistory *gHistory = nsnull;
|
nsISHistory *gHistory = nsnull;
|
||||||
nsIComponentManager *gComponentManager = nsnull;
|
nsIComponentManager *gComponentManager = nsnull;
|
||||||
static PRBool gFirstTime = PR_TRUE;
|
static PRBool gFirstTime = PR_TRUE;
|
||||||
static PLEventQueue * gActionQueue;
|
|
||||||
static PRThread * gEmbeddedThread;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,6 +373,11 @@ int processEventLoop(WebShellInitContext * initContext)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PENDING(edburns): revisit this. Not sure why this is necessary, but
|
||||||
|
// this fixes bug 44327
|
||||||
|
printf("%c", 8); // 8 is ASCII for backspace
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,12 +472,14 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||||
|
|
||||||
PR_ASSERT(gComponentManager);
|
PR_ASSERT(gComponentManager);
|
||||||
|
|
||||||
if (gFirstTime) {
|
|
||||||
nsCOMPtr<nsIEventQueueService>
|
nsCOMPtr<nsIEventQueueService>
|
||||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID);
|
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID);
|
||||||
|
|
||||||
// if we get here, we know that aEventQService is not null.
|
// if we get here, we know that aEventQService is not null.
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
if (!aEventQService) {
|
||||||
|
rv = NS_ERROR_FAILURE;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO Add tracing from nspr.
|
//TODO Add tracing from nspr.
|
||||||
|
|
||||||
|
@ -495,7 +500,6 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||||
// Create the event queue.
|
// Create the event queue.
|
||||||
rv = aEventQService->CreateThreadEventQueue();
|
rv = aEventQService->CreateThreadEventQueue();
|
||||||
initContext->embeddedThread = PR_GetCurrentThread();
|
initContext->embeddedThread = PR_GetCurrentThread();
|
||||||
gEmbeddedThread = initContext->embeddedThread;
|
|
||||||
|
|
||||||
// Create the action queue
|
// Create the action queue
|
||||||
if (initContext->embeddedThread) {
|
if (initContext->embeddedThread) {
|
||||||
|
@ -524,18 +528,12 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||||
|
|
||||||
EQueue->GetPLEventQueue(&plEventQueue);
|
EQueue->GetPLEventQueue(&plEventQueue);
|
||||||
initContext->actionQueue = plEventQueue;
|
initContext->actionQueue = plEventQueue;
|
||||||
gActionQueue = initContext->actionQueue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
initContext->initFailCode = kCreateWebShellError;
|
initContext->initFailCode = kCreateWebShellError;
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
initContext->embeddedThread = gEmbeddedThread;
|
|
||||||
initContext->actionQueue = gActionQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup Prefs obj and read default prefs
|
// Setup Prefs obj and read default prefs
|
||||||
if (gFirstTime) {
|
if (gFirstTime) {
|
||||||
|
@ -666,9 +664,6 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
||||||
("InitMozillaStuff(%lx): enter event loop\n", initContext));
|
("InitMozillaStuff(%lx): enter event loop\n", initContext));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
PRThread *thread = PR_GetCurrentThread();
|
|
||||||
printf("debug: edburns: InitMozillaStuff currentThread %p\n", thread);
|
|
||||||
|
|
||||||
// Just need to loop once to clear out events before returning
|
// Just need to loop once to clear out events before returning
|
||||||
processEventLoop(initContext);
|
processEventLoop(initContext);
|
||||||
|
|
||||||
|
|
|
@ -123,43 +123,17 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo
|
||||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeDestroyInitContext");
|
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeDestroyInitContext");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
wsDeallocateInitContextEvent * actionEvent =
|
||||||
|
new wsDeallocateInitContextEvent(initContext);
|
||||||
|
PLEvent * event = (PLEvent*) *actionEvent;
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
initContext->parentHWnd = nsnull;
|
rv = (nsresult) ::util_PostSynchronousEvent(initContext, event);
|
||||||
// ((nsISupports *)initContext->docShell)->Release();
|
if (NS_FAILED(rv)) {
|
||||||
initContext->docShell = nsnull;
|
::util_ThrowExceptionToJava(env, "Exception: Can't destroy initContext");
|
||||||
// ((nsISupports *)initContext->webShell)->Release();
|
return;
|
||||||
|
|
||||||
// PENDING(edburns): this is a leak. For some reason, webShell's
|
|
||||||
// refcount is two. I believe it should be one.
|
|
||||||
// see http://bugzilla.mozilla.org/show_bug.cgi?id=38271
|
|
||||||
|
|
||||||
initContext->webShell = nsnull;
|
|
||||||
initContext->webNavigation = nsnull;
|
|
||||||
initContext->presShell = nsnull;
|
|
||||||
initContext->sHistory = nsnull;
|
|
||||||
initContext->baseWindow = nsnull;
|
|
||||||
|
|
||||||
// PENDING(edburns): not sure if these need to be deleted
|
|
||||||
initContext->actionQueue = nsnull;
|
|
||||||
initContext->embeddedThread = nsnull;
|
|
||||||
initContext->env = nsnull;
|
|
||||||
if (nsnull != initContext->nativeEventThread) {
|
|
||||||
::util_DeleteGlobalRef(env, initContext->nativeEventThread);
|
|
||||||
initContext->nativeEventThread = nsnull;
|
|
||||||
}
|
}
|
||||||
initContext->stopThread = -1;
|
initContext->actionQueue = nsnull;
|
||||||
initContext->initComplete = FALSE;
|
|
||||||
initContext->initFailCode = 0;
|
|
||||||
initContext->x = -1;
|
|
||||||
initContext->y = -1;
|
|
||||||
initContext->w = -1;
|
|
||||||
initContext->h = -1;
|
|
||||||
initContext->gtkWinPtr = nsnull;
|
|
||||||
initContext->searchContext = nsnull;
|
|
||||||
initContext->currentDocument = nsnull;
|
|
||||||
initContext->propertiesClass = nsnull;
|
|
||||||
initContext->browserContainer = nsnull;
|
|
||||||
|
|
||||||
delete initContext;
|
delete initContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "nsISHEntry.h"
|
#include "nsISHEntry.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
|
|
||||||
|
#include "jni_util.h"
|
||||||
|
|
||||||
void * handleEvent (PLEvent * event);
|
void * handleEvent (PLEvent * event);
|
||||||
void destroyEvent (PLEvent * event);
|
void destroyEvent (PLEvent * event);
|
||||||
|
@ -664,5 +665,60 @@ wsAddDocLoaderObserverEvent::handleEvent ()
|
||||||
return result;
|
return result;
|
||||||
} // handleEvent()
|
} // handleEvent()
|
||||||
|
|
||||||
|
wsDeallocateInitContextEvent::wsDeallocateInitContextEvent(WebShellInitContext* yourInitContext) :
|
||||||
|
nsActionEvent(),
|
||||||
|
mInitContext(yourInitContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
wsDeallocateInitContextEvent::handleEvent ()
|
||||||
|
{
|
||||||
|
void *result = nsnull;
|
||||||
|
if (!mInitContext) {
|
||||||
|
return (void *) NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInitContext->parentHWnd = nsnull;
|
||||||
|
// ((nsISupports *)mInitContext->docShell)->Release();
|
||||||
|
mInitContext->docShell = nsnull;
|
||||||
|
// ((nsISupports *)mInitContext->webShell)->Release();
|
||||||
|
|
||||||
|
// PENDING(edburns): this is a leak. For some reason, webShell's
|
||||||
|
// refcount is two. I believe it should be one.
|
||||||
|
// see http://bugzilla.mozilla.org/show_bug.cgi?id=38271
|
||||||
|
|
||||||
|
mInitContext->webShell = nsnull;
|
||||||
|
mInitContext->webNavigation = nsnull;
|
||||||
|
mInitContext->presShell = nsnull;
|
||||||
|
mInitContext->sHistory = nsnull;
|
||||||
|
mInitContext->baseWindow = nsnull;
|
||||||
|
|
||||||
|
mInitContext->embeddedThread = nsnull;
|
||||||
|
mInitContext->env = nsnull;
|
||||||
|
if (nsnull != mInitContext->nativeEventThread) {
|
||||||
|
::util_DeleteGlobalRef((JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2),
|
||||||
|
mInitContext->nativeEventThread);
|
||||||
|
mInitContext->nativeEventThread = nsnull;
|
||||||
|
}
|
||||||
|
mInitContext->stopThread = -1;
|
||||||
|
mInitContext->initComplete = FALSE;
|
||||||
|
mInitContext->initFailCode = 0;
|
||||||
|
mInitContext->x = -1;
|
||||||
|
mInitContext->y = -1;
|
||||||
|
mInitContext->w = -1;
|
||||||
|
mInitContext->h = -1;
|
||||||
|
mInitContext->gtkWinPtr = nsnull;
|
||||||
|
mInitContext->searchContext = nsnull;
|
||||||
|
mInitContext->currentDocument = nsnull;
|
||||||
|
mInitContext->propertiesClass = nsnull;
|
||||||
|
mInitContext->browserContainer = nsnull;
|
||||||
|
|
||||||
|
// delete mInitContext;
|
||||||
|
|
||||||
|
return (void *) NS_OK;
|
||||||
|
} // handleEvent()
|
||||||
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "plevent.h"
|
#include "plevent.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
* Concrete subclasses of nsActionEvent are used to safely convey an
|
* Concrete subclasses of nsActionEvent are used to safely convey an
|
||||||
|
@ -342,6 +344,19 @@ protected:
|
||||||
nsIDocumentLoaderObserver *mDocObserver;
|
nsIDocumentLoaderObserver *mDocObserver;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WebShellInitContext;
|
||||||
|
|
||||||
|
class wsDeallocateInitContextEvent : public nsActionEvent {
|
||||||
|
public:
|
||||||
|
wsDeallocateInitContextEvent(WebShellInitContext *yourInitContext);
|
||||||
|
|
||||||
|
void * handleEvent (void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WebShellInitContext *mInitContext;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* nsActions_h___ */
|
#endif /* nsActions_h___ */
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче