mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-30 00:50:15 -05:00
#14306 Fix orphaned progress dialog when importing summary ensembles
Driving caf::ProgressInfo from worker threads inside the OpenMP loop in loadFileSummaryCaseData() marshaled setProgress() to the GUI thread via a queued connection. These updates could be delivered after the ProgressInfo scope had ended and the progress stacks were popped, accessing an empty stack and resurrecting the just-closed dialog stuck at 0% with no way to close it. Only update the progress dialog from the master thread, using an atomic counter for a monotonic progress value, and guard the ProgressInfo mutators against stale updates delivered after the stacks are empty.
This commit is contained in:
1 parent
2ac1948abe
commit
c0059da42c
2 files changed
+24
-3
No files matched your search
@@ -21,6 +21,7 @@
|
||||
#include "RiaEclipseFileNameTools.h"
|
||||
#include "RiaEnsembleNameTools.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaOpenMPTools.h"
|
||||
#include "RiaPreferencesSummary.h"
|
||||
#include "RiaPreferencesSystem.h"
|
||||
#include "RiaQStringFormatter.h"
|
||||
@@ -59,6 +60,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSummaryCaseMainCollection, "SummaryCaseCollection" );
|
||||
@@ -583,6 +585,8 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( const std::vector<Ri
|
||||
[[maybe_unused]] bool canUseMultipleThreads =
|
||||
( prefs->summaryDataReader() != RiaPreferencesSummary::SummaryReaderMode::HDF5_OPM_COMMON );
|
||||
|
||||
std::atomic<int> completedCount = 0;
|
||||
|
||||
#pragma omp parallel for schedule( dynamic ) if ( canUseMultipleThreads )
|
||||
for ( int cIdx = 0; cIdx < static_cast<int>( fileSummaryCases.size() ); ++cIdx )
|
||||
{
|
||||
@@ -611,7 +615,14 @@ void RimSummaryCaseMainCollection::loadFileSummaryCaseData( const std::vector<Ri
|
||||
}
|
||||
}
|
||||
|
||||
progInfo.setProgress( cIdx );
|
||||
int completed = ++completedCount;
|
||||
|
||||
// Only update progress from the GUI thread; worker-thread updates are marshaled via a
|
||||
// queued connection and may be delivered after this ProgressInfo scope has ended.
|
||||
if ( RiaOpenMPTools::currentThreadIndex() == 0 )
|
||||
{
|
||||
progInfo.setProgress( completed );
|
||||
}
|
||||
}
|
||||
for ( const auto& txt : threadSafeLogger.messages() )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user