Write and delete "application is running" marker file

This commit is contained in:
David Rowe 2015-08-24 11:09:41 -07:00
parent 07c9a0e2bb
commit 63ad972576
3 changed files with 73 additions and 0 deletions

View file

@ -104,6 +104,7 @@
#include <RenderableWebEntityItem.h>
#include "AudioClient.h"
#include "CrashHandler.h"
#include "DiscoverabilityManager.h"
#include "GLCanvas.h"
#include "LODManager.h"
@ -256,6 +257,9 @@ bool setupEssentials(int& argc, char** argv) {
// Set build version
QCoreApplication::setApplicationVersion(BUILD_VERSION);
CrashHandler::writeRunningMarkerFiler();
qAddPostRoutine(CrashHandler::deleteRunningMarkerFile);
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
DependencyManager::registerInheritance<EntityActionFactoryInterface, InterfaceActionFactory>();

View file

@ -0,0 +1,42 @@
//
// CrashHandler.cpp
// interface/src
//
// Created by David Rowe on 24 Aug 2015.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "CrashHandler.h"
#include <QCoreApplication>
#include <QFile>
#include <PathUtils.h>
#include <QSettings>
#include <QStandardPaths>
static const QString RUNNING_MARKER_FILENAME = "Interface.running";
void CrashHandler::writeRunningMarkerFiler() {
QFile runningMarkerFile(runningMarkerFilePath());
if (!runningMarkerFile.exists()) {
runningMarkerFile.open(QIODevice::WriteOnly);
runningMarkerFile.close();
}
}
void CrashHandler::deleteRunningMarkerFile() {
QFile runningMarkerFile(runningMarkerFilePath());
if (runningMarkerFile.exists()) {
runningMarkerFile.remove();
}
}
const QString CrashHandler::runningMarkerFilePath() {
QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
applicationInfo.beginGroup("INFO");
QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + RUNNING_MARKER_FILENAME;
}

View file

@ -0,0 +1,27 @@
//
// CrashHandler.h
// interface/src
//
// Created by David Rowe on 24 Aug 2015.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_CrashHandler_h
#define hifi_CrashHandler_h
#include <QString>
class CrashHandler {
public:
static void writeRunningMarkerFiler();
static void deleteRunningMarkerFile();
private:
static const QString runningMarkerFilePath();
};
#endif // hifi_CrashHandler_h