2010-03-30 15:34:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-30 15:34:37 +04:00
|
|
|
|
|
|
|
#include "nsQAppInstance.h"
|
|
|
|
#include <QApplication>
|
2011-10-18 04:53:37 +04:00
|
|
|
#ifdef MOZ_ENABLE_MEEGOTOUCH
|
|
|
|
#include <MComponentData>
|
|
|
|
#include <MApplicationService>
|
|
|
|
#endif
|
2010-05-24 16:21:52 +04:00
|
|
|
#include "prenv.h"
|
2011-10-18 04:53:37 +04:00
|
|
|
#include <stdlib.h>
|
2010-03-30 15:34:37 +04:00
|
|
|
|
2013-10-11 00:36:42 +04:00
|
|
|
QApplication *nsQAppInstance::sQAppInstance = nullptr;
|
2011-10-18 04:53:37 +04:00
|
|
|
#ifdef MOZ_ENABLE_MEEGOTOUCH
|
2013-10-11 00:36:42 +04:00
|
|
|
MComponentData* nsQAppInstance::sMComponentData = nullptr;
|
2011-10-18 04:53:37 +04:00
|
|
|
#endif
|
2010-03-30 15:34:37 +04:00
|
|
|
int nsQAppInstance::sQAppRefCount = 0;
|
|
|
|
|
2011-10-18 04:53:37 +04:00
|
|
|
void nsQAppInstance::AddRef(int& aArgc, char** aArgv, bool aDefaultProcess) {
|
|
|
|
if (qApp)
|
|
|
|
return;
|
2010-05-24 16:21:52 +04:00
|
|
|
if (!sQAppInstance) {
|
2013-02-26 00:25:16 +04:00
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
|
2011-10-18 04:53:37 +04:00
|
|
|
const char *graphicsSystem = getenv("MOZ_QT_GRAPHICSSYSTEM");
|
|
|
|
if (graphicsSystem) {
|
2010-05-24 16:21:52 +04:00
|
|
|
QApplication::setGraphicsSystem(QString(graphicsSystem));
|
2011-10-18 04:53:37 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
sQAppInstance = new QApplication(aArgc, aArgv);
|
2010-05-24 16:21:52 +04:00
|
|
|
}
|
2010-03-30 15:34:37 +04:00
|
|
|
sQAppRefCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsQAppInstance::Release(void) {
|
|
|
|
if (sQAppInstance && !--sQAppRefCount) {
|
2011-10-18 04:53:37 +04:00
|
|
|
#ifdef MOZ_ENABLE_MEEGOTOUCH
|
|
|
|
delete sMComponentData;
|
2013-10-11 00:36:42 +04:00
|
|
|
sMComponentData = nullptr;
|
2011-10-18 04:53:37 +04:00
|
|
|
#endif
|
2010-03-30 15:34:37 +04:00
|
|
|
delete sQAppInstance;
|
2013-10-11 00:36:42 +04:00
|
|
|
sQAppInstance = nullptr;
|
2010-03-30 15:34:37 +04:00
|
|
|
}
|
|
|
|
}
|