aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-08-02 09:54:16 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-08-02 09:54:16 +0200
commit85e9aa34266b2b141ee9b8d635bc976c4f3b0490 (patch)
tree4bf44c292e15967cad5b044f3f1e45a5d2455354
parent62e61c44e89f39d6ee3852b6bc3cf6eeeb12b7e4 (diff)
downloadnextpnr-85e9aa34266b2b141ee9b8d635bc976c4f3b0490.tar.gz
nextpnr-85e9aa34266b2b141ee9b8d635bc976c4f3b0490.tar.bz2
nextpnr-85e9aa34266b2b141ee9b8d635bc976c4f3b0490.zip
Handle CTRL-C for windows build
-rw-r--r--gui/application.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/gui/application.cc b/gui/application.cc
index 58dc23eb..aece5d2a 100644
--- a/gui/application.cc
+++ b/gui/application.cc
@@ -27,11 +27,24 @@
NEXTPNR_NAMESPACE_BEGIN
+#ifdef _WIN32
+#include <windows.h>
+BOOL WINAPI WinHandler(DWORD dwCtrlType)
+{
+ if (dwCtrlType == CTRL_C_EVENT)
+ qApp->quit();
+ return TRUE;
+}
+#endif
+
Application::Application(int &argc, char **argv) : QApplication(argc, argv)
{
QSurfaceFormat fmt;
fmt.setSamples(10);
QSurfaceFormat::setDefaultFormat(fmt);
+#ifdef _WIN32
+ SetConsoleCtrlHandler((PHANDLER_ROUTINE)WinHandler, TRUE);
+#endif
}
bool Application::notify(QObject *receiver, QEvent *event)