toolkit/xre/nsQAppInstance.cpp
author Kris Maglione <maglione.k@gmail.com>
Sat, 23 Apr 2016 20:41:14 -0700
changeset 294665 58fc5fb221e0eb4dfb23779215873fb870e980c4
parent 169789 c5953f75569b803a730ec277b1afca9ff9a6868f
permissions -rw-r--r--
Bug 1254194: Add a validator for custom add-on content security policies. r=billm f=aswan MozReview-Commit-ID: LtBbXBCFc32

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 et sw=2 tw=80: */
/* 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/. */

#include "nsQAppInstance.h"
#include <QGuiApplication>
#include "prenv.h"
#include "nsXPCOMPrivate.h"
#include <stdlib.h>

QGuiApplication *nsQAppInstance::sQAppInstance = nullptr;
int nsQAppInstance::sQAppRefCount = 0;

void nsQAppInstance::AddRef(int& aArgc, char** aArgv, bool aDefaultProcess) {
  if (qApp)
    return;
  if (!sQAppInstance) {
    mozilla::SetICUMemoryFunctions();
    sQAppInstance = new QGuiApplication(aArgc, aArgv);
  }
  sQAppRefCount++;
}

void nsQAppInstance::Release(void) {
  if (sQAppInstance && !--sQAppRefCount) {
    delete sQAppInstance;
    sQAppInstance = nullptr;
  }
}