pgLab/pglab/main.cpp
eelke dc8a052544 Basic concept of MenuAction is working
Module can register action
Window adds this action to its menu
Clicking the menu item for the action has the expected result
But menu structure still needs work (everything is now put into one dropdown menu)
2019-01-01 11:15:16 +01:00

53 lines
1.4 KiB
C++

#include "MasterController.h"
#include <QApplication>
#ifdef _WIN32
# include <winsock2.h>
#endif
#include <memory>
#include "GlobalIoService.h"
#include "plugin_support/PluginRegister.h"
int main(int argc, char *argv[])
{
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
#ifdef WIN32
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
int err = WSAStartup(wVersionRequested, &wsaData);
if (err != 0) {
/* Tell the user that we could not find a usable */
/* Winsock DLL. */
printf("WSAStartup failed with error: %d\n", err);
return 1;
}
#endif
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("pglab");
QCoreApplication::setOrganizationDomain("eelkeklein.nl");
QCoreApplication::setApplicationName("pglab");
PluginRegister::getInstance()->initModules();
std::thread asio_service_thread;
int result = -1;
{
auto ios = getGlobalAsioIoService();
boost::asio::io_service::work work(*ios); // Prevent service from running out of work so run doesn't return
asio_service_thread = std::thread([ios](){ ios->run(); });
// make sure the io_service is stopped before we wait on the future
auto master_controller = std::make_unique<MasterController>();
master_controller->init();
result = a.exec();
}
asio_service_thread.join();
#ifdef WIN32
WSACleanup();
#endif
return result;
}