Bug 554911 - mozilla-runtime process hang and not closed properly after closing fennec UI. r=dougt

This commit is contained in:
Oleg Romashin 2010-03-30 07:28:10 -04:00
Родитель b035d19290
Коммит 067551baf0
7 изменённых файлов: 134 добавлений и 30 удалений

Просмотреть файл

@ -36,10 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_WIDGET_QT
#include <QApplication>
#endif
#include "ContentProcessChild.h"
#include "TabChild.h"
@ -59,11 +55,6 @@
using namespace mozilla::ipc;
using namespace mozilla::net;
#ifdef MOZ_WIDGET_QT
extern int gArgc;
extern char **gArgv;
#endif
namespace mozilla {
namespace dom {
@ -88,11 +79,6 @@ ContentProcessChild::Init(MessageLoop* aIOLoop,
Open(aChannel, aParentHandle, aIOLoop);
sSingleton = this;
#ifdef MOZ_WIDGET_QT
NS_ASSERTION(!qApp, "QApplication created too early?");
mQApp = new QApplication(gArgc, (char**)gArgv);
#endif
return true;
}

Просмотреть файл

@ -44,10 +44,6 @@
#include "nsTArray.h"
#include "nsAutoPtr.h"
#ifdef MOZ_WIDGET_QT
class QApplication;
#endif
struct ChromePackage;
struct ResourceMapping;
struct OverrideMapping;
@ -99,9 +95,6 @@ private:
nsTArray<nsAutoPtr<PTestShellChild> > mTestShells;
PRBool mQuit;
#ifdef MOZ_WIDGET_QT
nsAutoPtr<QApplication> mQApp;
#endif
DISALLOW_EVIL_CONSTRUCTORS(ContentProcessChild);
};

Просмотреть файл

@ -79,6 +79,7 @@
#include <QX11EmbedWidget>
#include <QGraphicsView>
#include <QGraphicsWidget>
#include "nsQAppInstance.h"
#endif
#ifdef MOZ_WIDGET_GTK2
@ -113,6 +114,9 @@ TabChild::Init()
#ifdef MOZ_WIDGET_GTK2
gtk_init(NULL, NULL);
#endif
#ifdef MOZ_WIDGET_QT
nsQAppInstance::AddRef();
#endif
nsCOMPtr<nsIWebBrowser> webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
if (!webBrowser) {
@ -374,6 +378,9 @@ TabChild::~TabChild()
JS_DestroyContext(mCx);
}
}
#ifdef MOZ_WIDGET_QT
nsQAppInstance::Release();
#endif
}
NS_IMETHODIMP

Просмотреть файл

@ -38,7 +38,7 @@
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_WIDGET_QT
#include <QApplication>
#include "nsQAppInstance.h"
#endif
#include "mozilla/plugins/PluginModuleChild.h"
@ -68,9 +68,6 @@ using namespace mozilla::plugins;
namespace {
PluginModuleChild* gInstance = nsnull;
#ifdef MOZ_WIDGET_QT
static QApplication *gQApp = nsnull;
#endif
}
@ -97,9 +94,7 @@ PluginModuleChild::~PluginModuleChild()
PR_UnloadLibrary(mLibrary);
}
#ifdef MOZ_WIDGET_QT
if (gQApp)
delete gQApp;
gQApp = nsnull;
nsQAppInstance::Release();
#endif
gInstance = nsnull;
}
@ -462,8 +457,7 @@ PluginModuleChild::InitGraphics()
}
#elif defined(MOZ_WIDGET_QT)
if (!qApp)
gQApp = new QApplication(0, NULL);
nsQAppInstance::AddRef();
#else
// may not be necessary on all platforms
#endif

Просмотреть файл

@ -108,6 +108,8 @@ CPPSRCS += nsNativeAppSupportUnix.cpp
else
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += nsNativeAppSupportQt.cpp
CPPSRCS += nsQAppInstance.cpp
EXPORTS += nsQAppInstance.h
else
CPPSRCS += nsNativeAppSupportDefault.cpp
endif

Просмотреть файл

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 et sw=2 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsQAppInstance.h"
#include <QApplication>
// declared in nsAppRunner.cpp
extern int gArgc;
extern char **gArgv;
nsQAppInstance *nsQAppInstance::sQAppInstance = NULL;
int nsQAppInstance::sQAppRefCount = 0;
nsQAppInstance::nsQAppInstance(int gArgc, char** gArgv)
: QApplication(gArgc, gArgv)
{
}
void nsQAppInstance::AddRef(void) {
if (qApp) return;
if (!sQAppInstance)
sQAppInstance = new nsQAppInstance(gArgc, gArgv);
sQAppRefCount++;
}
void nsQAppInstance::Release(void) {
if (sQAppInstance && !--sQAppRefCount) {
delete sQAppInstance;
sQAppInstance = NULL;
}
}

Просмотреть файл

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 et sw=2 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Oleg Romashin <romaxa@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsQAppInstance_h
#define nsQAppInstance_h
#include <QApplication>
class nsQAppInstance : public QApplication
{
public:
static void AddRef(void);
static void Release(void);
private:
nsQAppInstance(int gArgc, char** gArgv);
static nsQAppInstance *sQAppInstance;
static int sQAppRefCount;
};
#endif /* nsQAppInstance_h */