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

--HG--
extra : rebase_source : 5490b2acfe1980e372b7918cf36e8e771b2a0747
This commit is contained in:
Oleg Romashin 2010-03-30 07:34:37 -04:00
parent 3f6f2843f5
commit b371b618cb
4 changed files with 127 additions and 9 deletions

View File

@ -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;
}
@ -460,8 +455,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

View File

@ -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

View File

@ -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;
}
}

View File

@ -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 */