summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAL <26797547+Al12rs@users.noreply.github.com>2020-06-07 18:51:02 +0200
committerAL <26797547+Al12rs@users.noreply.github.com>2020-06-07 18:51:02 +0200
commitd845fe9a74c9e0943defe5025b81c017a3fab41b (patch)
tree0331ff346f0885af0407af16b452d7371e03b2ff /src/mainwindow.cpp
parentd1c42e69c1819def3098bfac0fd96f2eb39226e9 (diff)
Make checks that occur at the same time not return immediately to avoid issues with stuff that might need to rely on check completion.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4a5175e6..1a868eec 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -267,7 +267,7 @@ MainWindow::MainWindow(Settings &settings
, m_LinkDesktop(nullptr)
, m_LinkStartMenu(nullptr)
, m_NumberOfProblems(0)
- , m_CheckingForProblems(false)
+ , m_ProblemsCheckRequired(false)
{
// disables incredibly slow menu fade in effect that looks and feels like crap.
// this was only happening to users with the windows
@@ -1107,27 +1107,26 @@ QFuture<void> MainWindow::checkForProblemsAsync() {
void MainWindow::checkForProblemsImpl()
{
TimeThis tt("MainWindow::checkForProblemsImpl()");
- {
- QMutexLocker lk(&m_CheckForProblemsMutex);
- if (m_CheckingForProblems) {
- return;
- }
- else {
- m_CheckingForProblems = true;
- }
- }
- size_t numProblems = 0;
- for (QObject *pluginObj : m_PluginContainer.plugins<QObject>()) {
- IPlugin *plugin = qobject_cast<IPlugin*>(pluginObj);
- if (plugin == nullptr || plugin->isActive()) {
- IPluginDiagnose *diagnose = qobject_cast<IPluginDiagnose*>(pluginObj);
- if (diagnose != nullptr)
- numProblems += diagnose->activeProblems().size();
+
+ m_ProblemsCheckRequired = true;
+
+ std::scoped_lock lk(m_CheckForProblemsMutex);
+
+ // another thread might already have checked while this one was waiting on the lock
+ if (m_ProblemsCheckRequired) {
+ m_ProblemsCheckRequired = false;
+ size_t numProblems = 0;
+ for (QObject *pluginObj : m_PluginContainer.plugins<QObject>()) {
+ IPlugin *plugin = qobject_cast<IPlugin*>(pluginObj);
+ if (plugin == nullptr || plugin->isActive()) {
+ IPluginDiagnose *diagnose = qobject_cast<IPluginDiagnose*>(pluginObj);
+ if (diagnose != nullptr)
+ numProblems += diagnose->activeProblems().size();
+ }
}
+ m_NumberOfProblems = numProblems;
+ emit checkForProblemsDone();
}
- m_NumberOfProblems = numProblems;
- m_CheckingForProblems = false;
- emit checkForProblemsDone();
}
void MainWindow::about()