[education/rkward/testing/win_citest_timeout] rkward: Try to fix thread exit
Thomas Friedrichsmeier
null at kde.org
Sun Oct 2 21:07:53 BST 2022
Git commit 6a6ad83f122e4e0d23e4423d5f0417c4f68f9bf3 by Thomas Friedrichsmeier.
Committed on 02/10/2022 at 20:07.
Pushed by tfry into branch 'testing/win_citest_timeout'.
Try to fix thread exit
M +5 -1 rkward/rbackend/rkrbackendprotocol_frontend.cpp
M +1 -1 rkward/windows/rkwindowcatcher.h
https://invent.kde.org/education/rkward/commit/6a6ad83f122e4e0d23e4423d5f0417c4f68f9bf3
diff --git a/rkward/rbackend/rkrbackendprotocol_frontend.cpp b/rkward/rbackend/rkrbackendprotocol_frontend.cpp
index fd09de28..c152298c 100644
--- a/rkward/rbackend/rkrbackendprotocol_frontend.cpp
+++ b/rkward/rbackend/rkrbackendprotocol_frontend.cpp
@@ -31,10 +31,14 @@ RKRBackendProtocolFrontend::~RKRBackendProtocolFrontend () {
RK_ASSERT(_instance == this);
terminateBackend ();
RKFrontendTransmitter::instance ()->wait(1000); // Wait for thread to catch the backend's exit request, and exit()
- RKFrontendTransmitter::instance ()->quit(); // Tell it to quit, otherwise
+ QMetaObject::invokeMethod(RKFrontendTransmitter::instance(), &RKFrontendTransmitter::quit, Qt::QueuedConnection);
+ RK_TRACE (RBACKEND);
RKFrontendTransmitter::instance ()->wait(3000); // Wait for thread to quit and clean up.
+ RK_TRACE (RBACKEND);
qApp->processEvents(QEventLoop::AllEvents, 500); // Not strictly needed, but avoids some mem leaks on exit by handling all posted BackendExit events
+ RK_TRACE (RBACKEND);
delete RKFrontendTransmitter::instance ();
+ RK_TRACE (RBACKEND);
_instance = nullptr;
}
diff --git a/rkward/windows/rkwindowcatcher.h b/rkward/windows/rkwindowcatcher.h
index 6284ccf3..2cc9dc4b 100644
--- a/rkward/windows/rkwindowcatcher.h
+++ b/rkward/windows/rkwindowcatcher.h
@@ -76,7 +76,7 @@ public:
/** remove a watch created with registerNameWatcher */
void unregisterWatcher (WId watched);
static RKWindowCatcher *instance ();
- static void discardInstance () { delete _instance; };
+ static void discardInstance () { delete _instance; _instance = nullptr; };
private:
void pollWatchedWindowStates ();
QTimer poll_timer;
More information about the rkward-tracker
mailing list