diff --git a/CMakeLists.txt b/CMakeLists.txt index 93763b59..905ec052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -500,13 +500,13 @@ if (WIN32) add_executable(${APP_PROJECT_NAME} ${APP_FILES} ${CMAKE_BINARY_DIR}/Sourcetrail.rc) - # hide the console when running a release build. + # also show the console when running a release build. set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE /DEBUG:FASTLINK") set_target_properties(${APP_PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE") set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") set_target_properties(${APP_PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE") - set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:WINDOWS /DEBUG") - set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") + set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/ENTRY:\"mainCRTStartup\" /SUBSYSTEM:CONSOLE /DEBUG") + set_target_properties(${APP_PROJECT_NAME} PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE") # generate pdb for release build set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") diff --git a/src/app/main.cpp b/src/app/main.cpp index e47e128d..49b628d1 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -217,7 +217,6 @@ int main(int argc, char *argv[]) if (commandLineParser.runWithoutGUI()) { - // headless Sourcetrail QtCoreApplication qtApp(argc, argv); @@ -291,7 +290,9 @@ int main(int argc, char *argv[]) } else { - +#ifdef _WIN32 + ShowWindow(GetConsoleWindow(), SW_HIDE); +#endif QtApplication qtApp(argc, argv); setupApp(argc, argv); diff --git a/src/lib_gui/platform_includes/includesWindows.h b/src/lib_gui/platform_includes/includesWindows.h index 7e757c84..e4fc5b04 100644 --- a/src/lib_gui/platform_includes/includesWindows.h +++ b/src/lib_gui/platform_includes/includesWindows.h @@ -3,6 +3,7 @@ #include #include +#include #include "vld.h" diff --git a/src/lib_gui/qt/utility/QtThreadedFunctor.h b/src/lib_gui/qt/utility/QtThreadedFunctor.h index c1d062ce..2613ee9c 100644 --- a/src/lib_gui/qt/utility/QtThreadedFunctor.h +++ b/src/lib_gui/qt/utility/QtThreadedFunctor.h @@ -8,7 +8,10 @@ #include #include -class QtThreadedFunctorHelper: public QObject +#include "utility/messaging/type/MessageWindowClosed.h" +#include "utility/messaging/MessageListener.h" + +class QtThreadedFunctorHelper: public QObject, public MessageListener { Q_OBJECT @@ -37,6 +40,14 @@ public: } private: + void handleMessage(MessageWindowClosed* message) override + { + // The QT thread probably won't relay signals anymore. So this stops other + // threads from getting stuck here (if they have less than 1000 open tasks, + // but that should be a reasonable assumption). + m_freeCallbacks.release(1000); + } + std::function m_callback; QSemaphore m_freeCallbacks; }; diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 9a06df32..4271b99c 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -379,7 +379,7 @@ void QtMainWindow::closeEvent(QCloseEvent* event) { log->setEnabled(false); } - MessageWindowClosed().dispatch(); + MessageWindowClosed().dispatchImmediately(); } void QtMainWindow::resizeEvent(QResizeEvent *event)