зеркало из 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,72 +472,67 @@ 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.
|
if (!aEventQService) {
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
|
return rv;
|
||||||
//TODO Add tracing from nspr.
|
}
|
||||||
|
|
||||||
|
//TODO Add tracing from nspr.
|
||||||
|
|
||||||
#if DEBUG_RAPTOR_CANVAS
|
#if DEBUG_RAPTOR_CANVAS
|
||||||
if (prLogModuleInfo) {
|
if (prLogModuleInfo) {
|
||||||
PR_LOG(prLogModuleInfo, 3,
|
PR_LOG(prLogModuleInfo, 3,
|
||||||
("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n",
|
("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n",
|
||||||
initContext));
|
initContext));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Create the Event Queue for the UI thread...
|
||||||
|
if (!aEventQService) {
|
||||||
|
initContext->initFailCode = kEventQueueError;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the event queue.
|
||||||
|
rv = aEventQService->CreateThreadEventQueue();
|
||||||
|
initContext->embeddedThread = PR_GetCurrentThread();
|
||||||
|
|
||||||
|
// Create the action queue
|
||||||
|
if (initContext->embeddedThread) {
|
||||||
|
|
||||||
// Create the Event Queue for the UI thread...
|
if (initContext->actionQueue == nsnull) {
|
||||||
if (!aEventQService) {
|
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
||||||
initContext->initFailCode = kEventQueueError;
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the event queue.
|
|
||||||
rv = aEventQService->CreateThreadEventQueue();
|
|
||||||
initContext->embeddedThread = PR_GetCurrentThread();
|
|
||||||
gEmbeddedThread = initContext->embeddedThread;
|
|
||||||
|
|
||||||
// Create the action queue
|
|
||||||
if (initContext->embeddedThread) {
|
|
||||||
|
|
||||||
if (initContext->actionQueue == nsnull) {
|
// We need to do something different for Unix
|
||||||
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
nsIEventQueue * EQueue = nsnull;
|
||||||
|
|
||||||
// We need to do something different for Unix
|
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
|
||||||
nsIEventQueue * EQueue = nsnull;
|
&EQueue);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
|
initContext->initFailCode = kCreateWebShellError;
|
||||||
&EQueue);
|
return rv;
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
initContext->initFailCode = kCreateWebShellError;
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef XP_UNIX
|
|
||||||
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
|
||||||
GDK_INPUT_READ,
|
|
||||||
event_processor_callback,
|
|
||||||
EQueue);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PLEventQueue * plEventQueue = nsnull;
|
|
||||||
|
|
||||||
EQueue->GetPLEventQueue(&plEventQueue);
|
|
||||||
initContext->actionQueue = plEventQueue;
|
|
||||||
gActionQueue = initContext->actionQueue;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
#ifdef XP_UNIX
|
||||||
initContext->initFailCode = kCreateWebShellError;
|
gdk_input_add(EQueue->GetEventQueueSelectFD(),
|
||||||
return NS_ERROR_UNEXPECTED;
|
GDK_INPUT_READ,
|
||||||
|
event_processor_callback,
|
||||||
|
EQueue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PLEventQueue * plEventQueue = nsnull;
|
||||||
|
|
||||||
|
EQueue->GetPLEventQueue(&plEventQueue);
|
||||||
|
initContext->actionQueue = plEventQueue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
initContext->embeddedThread = gEmbeddedThread;
|
initContext->initFailCode = kCreateWebShellError;
|
||||||
initContext->actionQueue = gActionQueue;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup Prefs obj and read default prefs
|
// Setup Prefs obj and read default prefs
|
||||||
|
@ -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 =
|
||||||
initContext->parentHWnd = nsnull;
|
new wsDeallocateInitContextEvent(initContext);
|
||||||
// ((nsISupports *)initContext->docShell)->Release();
|
PLEvent * event = (PLEvent*) *actionEvent;
|
||||||
initContext->docShell = nsnull;
|
nsresult rv;
|
||||||
// ((nsISupports *)initContext->webShell)->Release();
|
|
||||||
|
rv = (nsresult) ::util_PostSynchronousEvent(initContext, event);
|
||||||
// PENDING(edburns): this is a leak. For some reason, webShell's
|
if (NS_FAILED(rv)) {
|
||||||
// refcount is two. I believe it should be one.
|
::util_ThrowExceptionToJava(env, "Exception: Can't destroy initContext");
|
||||||
// see http://bugzilla.mozilla.org/show_bug.cgi?id=38271
|
return;
|
||||||
|
}
|
||||||
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->actionQueue = nsnull;
|
||||||
initContext->embeddedThread = nsnull;
|
|
||||||
initContext->env = nsnull;
|
|
||||||
if (nsnull != initContext->nativeEventThread) {
|
|
||||||
::util_DeleteGlobalRef(env, initContext->nativeEventThread);
|
|
||||||
initContext->nativeEventThread = nsnull;
|
|
||||||
}
|
|
||||||
initContext->stopThread = -1;
|
|
||||||
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___ */
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче