diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-02-16 02:26:21 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-02-16 09:42:09 +0000 |
commit | f2004660668895eb7858f89a9cc26acea5474013 (patch) | |
tree | 50eec02bb66926364430a868a46c7a71612da0d8 /src/plugins/classview/classviewmanager.cpp | |
parent | 4a15f6d16bbcd4ec6a75dd03ef38657264982b82 (diff) |
ClassView: Stop the running timer in Parser thread on close
When we are going to delete Parser object, it may happen,
that its timer is still being active. A call to
parserThread.quit() won't stop the timer. When we quit the
thread and wait for it to finish, the thread's timer may
still be active. Then we delete the Parser in the main thread,
what cause the following warning to appear:
"QObject::killTimer: Timers cannot be stopped from another thread".
In order to fix it, we post a request to the parser's thread
for stopping the timer by a call to aboutToShutdown() with
Qt::BlockingQueuedConnection, just before quitting the thread,
as the thread's event loop should still be spinning and is
able to receive and handle our request. It's the only safe way
to stop the active timer that was started in another thread
- it must be stopped it the same thread it was started in.
Inside the call to aboutToShutdown() we mark that we don't want
to start the timer anymore with m_shuttingDown flag and we stop
the timer. After the blocking call returns to the main thread
we are sure that the timer is not active anymore and it won't
became active in the future, so we safely quit the thread and
delete the timer.
Task-number: QTCREATORBUG-25317
Change-Id: I3b95c062b5561588c45c223d8588b2b700ad4040
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/classview/classviewmanager.cpp')
-rw-r--r-- | src/plugins/classview/classviewmanager.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index 8284071d21..338c1eb357 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -123,6 +123,7 @@ Manager::Manager(QObject *parent) Manager::~Manager() { + QMetaObject::invokeMethod(&d->parser, &Parser::aboutToShutdown, Qt::BlockingQueuedConnection); d->parserThread.quit(); d->parserThread.wait(); delete d; |