зеркало из 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;
|
||||
nsIComponentManager *gComponentManager = nsnull;
|
||||
static PRBool gFirstTime = PR_TRUE;
|
||||
static PLEventQueue * gActionQueue;
|
||||
static PRThread * gEmbeddedThread;
|
||||
|
||||
|
||||
|
||||
|
@ -375,6 +373,11 @@ int processEventLoop(WebShellInitContext * initContext)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -469,72 +472,67 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
|||
|
||||
PR_ASSERT(gComponentManager);
|
||||
|
||||
if (gFirstTime) {
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID);
|
||||
|
||||
// if we get here, we know that aEventQService is not null.
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
//TODO Add tracing from nspr.
|
||||
|
||||
nsCOMPtr<nsIEventQueueService>
|
||||
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID);
|
||||
|
||||
// if we get here, we know that aEventQService is not null.
|
||||
if (!aEventQService) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//TODO Add tracing from nspr.
|
||||
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n",
|
||||
initContext));
|
||||
}
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n",
|
||||
initContext));
|
||||
}
|
||||
#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 (!aEventQService) {
|
||||
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) {
|
||||
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
||||
|
||||
if (initContext->actionQueue == nsnull) {
|
||||
printf("InitMozillaStuff(%lx): Create the action queue\n", initContext);
|
||||
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
|
||||
&EQueue);
|
||||
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;
|
||||
// We need to do something different for Unix
|
||||
nsIEventQueue * EQueue = nsnull;
|
||||
|
||||
rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread,
|
||||
&EQueue);
|
||||
if (NS_FAILED(rv)) {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
initContext->embeddedThread = gEmbeddedThread;
|
||||
initContext->actionQueue = gActionQueue;
|
||||
initContext->initFailCode = kCreateWebShellError;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Setup Prefs obj and read default prefs
|
||||
|
@ -666,9 +664,6 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext)
|
|||
("InitMozillaStuff(%lx): enter event loop\n", initContext));
|
||||
}
|
||||
#endif
|
||||
PRThread *thread = PR_GetCurrentThread();
|
||||
printf("debug: edburns: InitMozillaStuff currentThread %p\n", thread);
|
||||
|
||||
// Just need to loop once to clear out events before returning
|
||||
processEventLoop(initContext);
|
||||
|
||||
|
|
|
@ -123,43 +123,17 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo
|
|||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to nativeDestroyInitContext");
|
||||
return;
|
||||
}
|
||||
|
||||
initContext->parentHWnd = nsnull;
|
||||
// ((nsISupports *)initContext->docShell)->Release();
|
||||
initContext->docShell = nsnull;
|
||||
// ((nsISupports *)initContext->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
|
||||
|
||||
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
|
||||
wsDeallocateInitContextEvent * actionEvent =
|
||||
new wsDeallocateInitContextEvent(initContext);
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
nsresult rv;
|
||||
|
||||
rv = (nsresult) ::util_PostSynchronousEvent(initContext, event);
|
||||
if (NS_FAILED(rv)) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: Can't destroy initContext");
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsISHEntry.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
void * handleEvent (PLEvent * event);
|
||||
void destroyEvent (PLEvent * event);
|
||||
|
@ -664,5 +665,60 @@ wsAddDocLoaderObserverEvent::handleEvent ()
|
|||
return result;
|
||||
} // 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
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
#include "nsString.h"
|
||||
#include "plevent.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Concrete subclasses of nsActionEvent are used to safely convey an
|
||||
|
@ -342,6 +344,19 @@ protected:
|
|||
nsIDocumentLoaderObserver *mDocObserver;
|
||||
};
|
||||
|
||||
struct WebShellInitContext;
|
||||
|
||||
class wsDeallocateInitContextEvent : public nsActionEvent {
|
||||
public:
|
||||
wsDeallocateInitContextEvent(WebShellInitContext *yourInitContext);
|
||||
|
||||
void * handleEvent (void);
|
||||
|
||||
protected:
|
||||
WebShellInitContext *mInitContext;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsActions_h___ */
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче