Bug 554008 - QApplication init must be initialized in ContentProcessChild, not in TabChild. r=smaug

This commit is contained in:
Oleg Romashin 2010-03-22 16:31:47 +02:00
parent 69b885991b
commit bff94e11ae
3 changed files with 20 additions and 15 deletions

View File

@ -36,6 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_WIDGET_QT
#include <QApplication>
#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()

View File

@ -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<nsAutoPtr<PTestShellChild> > mTestShells;
PRBool mQuit;
#ifdef MOZ_WIDGET_QT
nsAutoPtr<QApplication> mQApp;
#endif
DISALLOW_EVIL_CONSTRUCTORS(ContentProcessChild);
};

View File

@ -69,7 +69,6 @@
#ifdef MOZ_WIDGET_QT
#include <QX11EmbedWidget>
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsWidget>
#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<nsIWebBrowser> 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<nsIWebBrowser> webBrowser = do_QueryInterface(mWebNav);
if (webBrowser) {