# HG changeset patch # User František Kučera # Date 1538220393 -7200 # Node ID b6f790137bb8bc40f9cf422f0474a5a52d83a424 # Parent 547a7c5681a5b72f0f67ffb666fece1738e9eb7c Do not destroy background thread before application end. Avoids "QThread: Destroyed while thread is still running" and SIGABRT / core dump. This error occured when the thread was still reading STDIN (no EOF yet) and the window was closed. diff -r 547a7c5681a5 -r b6f790137bb8 nbproject/configurations.xml --- a/nbproject/configurations.xml Sat Sep 29 12:58:04 2018 +0200 +++ b/nbproject/configurations.xml Sat Sep 29 13:26:33 2018 +0200 @@ -139,6 +139,12 @@ /usr/include/x86_64-linux-gnu/qt5/QtCore + + QT_CHARTS_LIB + QT_CORE_LIB + QT_GUI_LIB + QT_WIDGETS_LIB + @@ -186,6 +192,23 @@ + /usr/include/x86_64-linux-gnu/qt5/QtCore + build/Debug/src + src + build/Debug/src/relpipe-out-chart_autogen/include + ../relpipe-lib-reader.cpp/include + ../relpipe-lib-cli.cpp/include + /usr/include/x86_64-linux-gnu/qt5 + /usr/include/x86_64-linux-gnu/qt5/QtWidgets + /usr/include/x86_64-linux-gnu/qt5/QtGui + /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ + /usr/include/x86_64-linux-gnu/qt5/QtCharts + + + + + + build/Debug/src src build/Debug/src/relpipe-out-chart_autogen/include @@ -198,30 +221,6 @@ /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ /usr/include/x86_64-linux-gnu/qt5/QtCharts - - QT_CHARTS_LIB - QT_CORE_LIB - QT_GUI_LIB - QT_WIDGETS_LIB - - - - - - - /usr/include/x86_64-linux-gnu/qt5/QtCore - ../relpipe-lib-cli.cpp/include/relpipe/cli - ../relpipe-lib-reader.cpp/include/relpipe/reader/handlers - src - /usr/include/x86_64-linux-gnu/qt5/QtGui - /usr/include/x86_64-linux-gnu/qt5/QtWidgets - ../relpipe-lib-reader.cpp/include/relpipe/reader - build/Debug/src/relpipe-out-chart_autogen/include - ../relpipe-lib-cli.cpp/include - ../relpipe-lib-reader.cpp/include - /usr/include/x86_64-linux-gnu/qt5 - build/Debug/src - diff -r 547a7c5681a5 -r b6f790137bb8 src/relpipe-out-chart.cpp --- a/src/relpipe-out-chart.cpp Sat Sep 29 12:58:04 2018 +0200 +++ b/src/relpipe-out-chart.cpp Sat Sep 29 13:26:33 2018 +0200 @@ -24,6 +24,7 @@ WorkerThread(std::shared_ptr reader) : reader(reader) { + setTerminationEnabled(true); } void run() { @@ -31,6 +32,7 @@ reader->process(); } catch (RelpipeReaderException& e) { // TODO: handle exception, show error dialog + std::wcerr << L"RelpipeReaderException: " << e.getMessge() << std::endl; } } }; @@ -67,5 +69,13 @@ app.exec(); //return app.exec(); + if (t.isRunning()) { + std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl; + t.terminate(); + std::wcerr << L"Background RelationalReader thread was terminated → wait()" << std::endl; + t.wait(); + std::wcerr << L"Background RelationalReader thread wait() finished" << std::endl; + } + return resultCode; }