|
|
@ -1,6 +1,7 @@
|
|
|
|
#include "editor.hpp"
|
|
|
|
#include "editor.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QLocalServer>
|
|
|
|
#include <QLocalServer>
|
|
|
|
#include <QLocalSocket>
|
|
|
|
#include <QLocalSocket>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QMessageBox>
|
|
|
@ -22,6 +23,7 @@
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <components/windows.hpp>
|
|
|
|
#include <components/windows.hpp>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <components/debug/debugging.hpp>
|
|
|
|
#include <components/debug/debugging.hpp>
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
#include <components/esm3/esmreader.hpp>
|
|
|
|
#include <components/esm3/esmreader.hpp>
|
|
|
@ -42,8 +44,8 @@ CS::Editor::Editor(int argc, char** argv)
|
|
|
|
: mConfigVariables(readConfiguration())
|
|
|
|
: mConfigVariables(readConfiguration())
|
|
|
|
, mSettingsState(mCfgMgr)
|
|
|
|
, mSettingsState(mCfgMgr)
|
|
|
|
, mDocumentManager(mCfgMgr)
|
|
|
|
, mDocumentManager(mCfgMgr)
|
|
|
|
, mPid("")
|
|
|
|
, mPid(std::filesystem::temp_directory_path() / "openmw-cs.pid")
|
|
|
|
, mLock()
|
|
|
|
, mLockFile(QFileInfo(mPid.c_str()).absoluteFilePath() + ".lock")
|
|
|
|
, mMerge(mDocumentManager)
|
|
|
|
, mMerge(mDocumentManager)
|
|
|
|
, mIpcServerName("org.openmw.OpenCS")
|
|
|
|
, mIpcServerName("org.openmw.OpenCS")
|
|
|
|
, mServer(nullptr)
|
|
|
|
, mServer(nullptr)
|
|
|
@ -95,6 +97,7 @@ CS::Editor::~Editor()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete mViewManager;
|
|
|
|
delete mViewManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mLockFile.unlock();
|
|
|
|
mPidFile.close();
|
|
|
|
mPidFile.close();
|
|
|
|
|
|
|
|
|
|
|
|
if (mServer && std::filesystem::exists(mPid))
|
|
|
|
if (mServer && std::filesystem::exists(mPid))
|
|
|
@ -336,14 +339,11 @@ bool CS::Editor::makeIPCServer()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mPid = std::filesystem::temp_directory_path();
|
|
|
|
|
|
|
|
mPid /= "openmw-cs.pid";
|
|
|
|
|
|
|
|
bool pidExists = std::filesystem::exists(mPid);
|
|
|
|
bool pidExists = std::filesystem::exists(mPid);
|
|
|
|
|
|
|
|
|
|
|
|
mPidFile.open(mPid);
|
|
|
|
mPidFile.open(mPid);
|
|
|
|
|
|
|
|
|
|
|
|
mLock = boost::interprocess::file_lock(mPid.c_str());
|
|
|
|
if (!mLockFile.tryLock())
|
|
|
|
if (!mLock.try_lock())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log(Debug::Error) << "Error: OpenMW-CS is already running.";
|
|
|
|
Log(Debug::Error) << "Error: OpenMW-CS is already running.";
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|