diff --git a/dom/ipc/ContentProcessChild.cpp b/dom/ipc/ContentProcessChild.cpp index 7699ef2c51fe..9d80f841c574 100644 --- a/dom/ipc/ContentProcessChild.cpp +++ b/dom/ipc/ContentProcessChild.cpp @@ -36,6 +36,10 @@ * * ***** END LICENSE BLOCK ***** */ +#ifdef MOZ_WIDGET_QT +#include +#endif + #include "ContentProcessChild.h" #include "TabChild.h" @@ -50,6 +54,11 @@ using namespace mozilla::ipc; using namespace mozilla::net; +#ifdef MOZ_WIDGET_QT +extern int gArgc; +extern char **gArgv; +#endif + namespace mozilla { namespace dom { @@ -58,6 +67,10 @@ ContentProcessChild* ContentProcessChild::sSingleton; ContentProcessChild::ContentProcessChild() : mQuit(PR_FALSE) { +#ifdef MOZ_WIDGET_QT + NS_ASSERTION(!qApp, "QApplication created too early?"); + mQApp = new QApplication(gArgc, (char**)gArgv); +#endif } ContentProcessChild::~ContentProcessChild() diff --git a/dom/ipc/ContentProcessChild.h b/dom/ipc/ContentProcessChild.h index 44d2c54a7865..8c465d89e539 100644 --- a/dom/ipc/ContentProcessChild.h +++ b/dom/ipc/ContentProcessChild.h @@ -44,6 +44,10 @@ #include "nsTArray.h" #include "nsAutoPtr.h" +#ifdef MOZ_WIDGET_QT +class QApplication; +#endif + namespace mozilla { namespace dom { @@ -83,6 +87,9 @@ private: nsTArray > mTestShells; PRBool mQuit; +#ifdef MOZ_WIDGET_QT + nsAutoPtr mQApp; +#endif DISALLOW_EVIL_CONSTRUCTORS(ContentProcessChild); }; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index ac116e608943..8fc97ef760d5 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -69,7 +69,6 @@ #ifdef MOZ_WIDGET_QT #include -#include #include #include #endif @@ -81,12 +80,6 @@ using namespace mozilla::dom; -#ifdef MOZ_WIDGET_QT -static QApplication *gQApp = nsnull; -extern int gArgc; -extern char **gArgv; -#endif - NS_IMPL_ISUPPORTS1(ContentListener, nsIDOMEventListener) NS_IMETHODIMP @@ -109,9 +102,6 @@ TabChild::Init() { #ifdef MOZ_WIDGET_GTK2 gtk_init(NULL, NULL); -#elif defined(MOZ_WIDGET_QT) - if (!qApp) - gQApp = new QApplication(gArgc, (char**)gArgv); #endif nsCOMPtr webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID); @@ -357,11 +347,6 @@ TabChild::destroyWidget() TabChild::~TabChild() { -#ifdef MOZ_WIDGET_QT - if (gQApp) - delete gQApp; - gQApp = nsnull; -#endif destroyWidget(); nsCOMPtr webBrowser = do_QueryInterface(mWebNav); if (webBrowser) {