openmw-tes3coop/apps/opencs/main.cpp
Marc Bouvier 51332b86a1 [Feature #811] Only 1 Instance of OpenCS is Allowed
If another instance of OpenCS is started, then it will terminate. This
is done by creating a QLocalServer with a unique ID. If another
QLocalServer with the same ID attempts to be opened, then the creation
of the QLocalServer will fail and the application will terminate.
2013-09-03 01:44:21 -05:00

48 lines
926 B
C++

#include "editor.hpp"
#include <exception>
#include <iostream>
#include <QApplication>
#include <QIcon>
class Application : public QApplication
{
private:
bool notify (QObject *receiver, QEvent *event)
{
try
{
return QApplication::notify (receiver, event);
}
catch (const std::exception& exception)
{
std::cerr << "An exception has been caught: " << exception.what() << std::endl;
}
return false;
}
public:
Application (int& argc, char *argv[]) : QApplication (argc, argv) {}
};
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE (resources);
Application mApplication (argc, argv);
mApplication.setWindowIcon (QIcon (":./opencs.png"));
CS::Editor editor;
if(!editor.makeIPCServer())
{
return 0;
}
return editor.run();
}