mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-27 20:44:13 +02:00
Merge pull request #995 from ispyisail/revive/713-collection-cancel-race
Cancel the collection-loading map before waiting on it in ~ElementsCollectionModel
This commit is contained in:
@@ -49,6 +49,14 @@ ElementsCollectionModel::ElementsCollectionModel(QObject *parent) :
|
||||
*/
|
||||
ElementsCollectionModel::~ElementsCollectionModel()
|
||||
{
|
||||
// Without cancel(), the wait below runs the whole queued
|
||||
// QtConcurrent::map() to completion, so closing this dialog on a
|
||||
// large collection blocks until every remaining item has been
|
||||
// processed -- a visible hang on the button pressed precisely to
|
||||
// stop the work. cancel() drops the not-yet-started items so the
|
||||
// wait that follows (still needed, so an in-flight item can't
|
||||
// dereference this object after it's gone) is short.
|
||||
m_future.cancel();
|
||||
m_future.waitForFinished();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user