#4712 Fix stray widgets in Plot Property Panel

Added comments showing that the reason is mainly deleteLater beeing called outside all event loops
This commit is contained in:
Jacob Støren 2019-09-25 13:09:47 +02:00
parent 3f7fde5227
commit bfff15568d
3 changed files with 31 additions and 23 deletions

View File

@ -86,7 +86,14 @@ int main( int argc, char* argv[] )
QLocale::setDefault( QLocale( QLocale::English, QLocale::UnitedStates ) );
setlocale( LC_NUMERIC, "C" );
// Handle the command line arguments.
// Todo: Move to a one-shot timer, delaying the execution until we are inside the event loop.
// The complete handling of the resulting ApplicationStatus must be moved along.
// The reason for this is: deleteLater() does not work outside the event loop
// Make execution of command line stuff operate in identical conditions as interactive operation.
RiaApplication::ApplicationStatus status = app->handleArguments( &progOpt );
if ( status == RiaApplication::EXIT_COMPLETED )
{
return 0;

View File

@ -52,6 +52,7 @@
#include "RimSummaryPlotCollection.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include <QFileInfo>
@ -178,7 +179,6 @@ RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSu
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -406,6 +406,11 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
QStringList gridResultAddressFilters;
QStringList summaryAddressFilters;
RimSummaryPlot* lastPlotCreated = nullptr;
RimSummaryPlotCollection* sumPlotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
splitAddressFiltersInGridAndSummary( summaryCasesToUse[0],
allCurveAddressFilters,
&summaryAddressFilters,
@ -413,10 +418,6 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
if ( summaryAddressFilters.size() )
{
RimSummaryPlotCollection* sumPlotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
RimSummaryPlot* lastPlotCreated = nullptr;
RimSummaryCaseCollection* ensemble = nullptr;
if ( isEnsembleMode )
@ -479,11 +480,6 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
newPlot->applyDefaultCurveAppearances();
newPlot->loadDataAndUpdate();
sumPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::setExpanded( newPlot );
RiuPlotMainWindowTools::selectAsCurrentItem( newPlot );
}
else // Multiplot, one for each separate summary address
{
@ -556,16 +552,6 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
}
}
}
sumPlotColl->updateConnectedEditors();
if ( lastPlotCreated )
{
RiuPlotMainWindowTools::setExpanded( lastPlotCreated );
RiuPlotMainWindowTools::selectAsCurrentItem( lastPlotCreated );
RiuPlotMainWindowTools::showPlotMainWindow();
RiuMainWindow::instance()->close();
}
}
// Grid Cell Result vectors
@ -576,9 +562,6 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
std::vector<RimEclipseCase*> gridCasesToPlotFrom = openEclipseCasesForCellPlotting( gridFileNames );
RimSummaryPlotCollection* sumPlotColl =
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
if ( isSinglePlot )
{
std::vector<RimGridTimeHistoryCurve*> createdCurves;
@ -632,6 +615,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
newPlot->showLegend( !hideLegend );
newPlot->setNormalizationEnabled( isNormalizedY );
newPlot->loadDataAndUpdate();
lastPlotCreated = newPlot;
}
}
else // Multiplot
@ -683,14 +667,27 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
newPlot->showLegend( !hideLegend );
newPlot->setNormalizationEnabled( isNormalizedY );
newPlot->loadDataAndUpdate();
lastPlotCreated = newPlot;
}
}
}
}
}
if ( lastPlotCreated )
{
sumPlotColl->updateConnectedEditors();
RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow();
// Needed to avoid unneccessary activation of sub windows (plots)
// which results in population of property editor, and missing deleteLater because we are outside any event loop
// when switching object. Results in stray widgets.
mpw->setBlockSlotSubWindowActivated( true );
RiuPlotMainWindowTools::showPlotMainWindow();
mpw->setBlockSlotSubWindowActivated( false );
RiuPlotMainWindowTools::setExpanded( lastPlotCreated );
RiuPlotMainWindowTools::selectAsCurrentItem( lastPlotCreated );
RiuMainWindow::instance()->close();
}
}

View File

@ -66,6 +66,10 @@ PdmUiFieldEditorHandle::PdmUiFieldEditorHandle()
//--------------------------------------------------------------------------------------------------
PdmUiFieldEditorHandle::~PdmUiFieldEditorHandle()
{
// Note : deleteLater will not work unless you are actually inside an event loop.
// See https://doc.qt.io/qt-5/qobject.html#deleteLater
// Although it states that they will be deleted at startup of the event loop, it seems as that is not happening.
if (!m_combinedWidget.isNull()) m_combinedWidget->deleteLater();
if (!m_editorWidget.isNull()) m_editorWidget->deleteLater();
if (!m_labelWidget.isNull()) m_labelWidget->deleteLater();