diff --git a/BUILD b/BUILD index 7ff14d1..017087d 100644 --- a/BUILD +++ b/BUILD @@ -2,3 +2,12 @@ If it doesn't detect Qt CMAKE_PREFIX_PATH needs to be set export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/cmake + +Dependencies: +- Botan-2 +- libpq +- Qt5 +- fmt (should we include this one in the project? + + +- jsoncpp (included) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72a6af4..5b4e800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1.0) project(pglaball) set (CMAKE_PREFIX_PATH /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/cmake) +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") find_package(PkgConfig REQUIRED) @@ -52,8 +53,11 @@ include_directories( ${Qt5Widgets_INCLUDE_DIRS} ) find_package(fmt 4.0 REQUIRED) include_directories( ${fmt_INCLUDE_DIRS} ) -#find_package(Boost 1.62 REQUIRED) # COMPONENTS program_options REQUIRED ) -#include_directories( ${Boost_INCLUDE_DIRS} ) +#find_package(Libevent 2.0 REQUIRED) +#include_directories( ${Libevent_INCLUDE_DIRS} ) + +find_package(Boost 1.63 COMPONENTS system REQUIRED ) +include_directories( ${Boost_INCLUDE_DIRS} ) add_library(core STATIC core/BackupFormatModel.cpp @@ -75,6 +79,7 @@ add_executable(pglab pglab/DatabasesTableModel.cpp pglab/DatabaseWindow.cpp pglab/ExplainTreeModelItem.cpp + pglab/GlobalIoService.cpp pglab/jsoncpp.cpp pglab/main.cpp pglab/MainWindow.cpp diff --git a/pglab/GlobalIoService.cpp b/pglab/GlobalIoService.cpp new file mode 100644 index 0000000..99ddd2b --- /dev/null +++ b/pglab/GlobalIoService.cpp @@ -0,0 +1,7 @@ +#include "GlobalIoService.h" + +std::shared_ptr getGlobalAsioIoService() +{ + static auto ios = std::make_shared(); + return ios; +} diff --git a/pglab/GlobalIoService.h b/pglab/GlobalIoService.h new file mode 100644 index 0000000..5e92327 --- /dev/null +++ b/pglab/GlobalIoService.h @@ -0,0 +1,6 @@ +#pragma once + +#include +#include + +std::shared_ptr getGlobalAsioIoService(); diff --git a/pglab/MasterController.h b/pglab/MasterController.h index 68b4bd1..562e9ee 100644 --- a/pglab/MasterController.h +++ b/pglab/MasterController.h @@ -2,8 +2,10 @@ #define MASTERCONTROLLER_H #include +#include #include + class ConnectionConfig; class ConnectionList; class ConnectionListModel; @@ -30,7 +32,7 @@ public: void openSqlWindowForConnection(int connection_index); void openServerWindowForConnection(int connection_index); void openBackupDlgForConnection(int connection_index); - + signals: public slots: @@ -39,6 +41,7 @@ private: ConnectionList *m_connectionList = nullptr; ConnectionListModel *m_connectionListModel = nullptr; ConnectionManagerWindow *m_connectionManagerWindow = nullptr; + }; #endif // MASTERCONTROLLER_H diff --git a/pglab/QueryTab.cpp b/pglab/QueryTab.cpp index d2c0c15..bcb7bd6 100644 --- a/pglab/QueryTab.cpp +++ b/pglab/QueryTab.cpp @@ -20,7 +20,6 @@ #include "PgsqlDatabaseCatalogue.h" #include "util.h" - QueryParamListController::QueryParamListController(QTableView *tv, OpenDatabase *opendb, QWidget *parent) : QObject(parent) diff --git a/pglab/main.cpp b/pglab/main.cpp index c4f3139..505265d 100644 --- a/pglab/main.cpp +++ b/pglab/main.cpp @@ -4,12 +4,13 @@ # include #endif #include +#include "GlobalIoService.h" int main(int argc, char *argv[]) { /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ -#ifdef _WIN32 +#ifdef WIN32 WORD wVersionRequested = MAKEWORD(2, 2); WSADATA wsaData; int err = WSAStartup(wVersionRequested, &wsaData); @@ -20,16 +21,27 @@ int main(int argc, char *argv[]) return 1; } #endif + QApplication a(argc, argv); QCoreApplication::setOrganizationName("pglab"); QCoreApplication::setOrganizationDomain("eelkeklein.nl"); QCoreApplication::setApplicationName("pglab"); - auto master_controller = std::make_unique(); - master_controller->init(); - int result = a.exec(); -#ifdef _WIN32 + 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(); + master_controller->init(); + result = a.exec(); + } + asio_service_thread.join(); +#ifdef WIN32 WSACleanup(); #endif return result;