RegressionTests: Fix performance issues related to DockManager::restoreState

* Performance: Disable DockManager::restoreState when running regression tests
* Set parent to Qt widgets to avoid memory leak
* Change singleton pattern to avoid memory leak
This commit is contained in:
Magne Sjaastad 2022-12-22 15:35:45 +01:00 committed by GitHub
parent 5d072663f1
commit 9db4d03a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 13 deletions

View File

@ -21,6 +21,7 @@
#include "RiaApplication.h"
#include "RiaDefines.h"
#include "RiaPreferences.h"
#include "RiaRegressionTestRunner.h"
#include "RiaVersionInfo.h"
#include "RiuDockWidgetTools.h"
@ -151,7 +152,6 @@ void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
QVariant winGeo = settings.value( QString( "%1/winGeometry" ).arg( registryFolderName() ) );
QVariant toolbarLayout = settings.value( QString( "%1/toolBarLayout" ).arg( registryFolderName() ) );
QVariant dockState = settings.value( QString( "%1/dockLayout" ).arg( registryFolderName() ) );
if ( winGeo.isValid() )
{
@ -164,7 +164,13 @@ void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
}
}
if ( !RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
// Performance of m_dockManager->restoreState() is very bad is degrading as more and more regression tests are
// launched. Disable restore of state for regression test.
bool dockingOk = false;
QVariant dockState = settings.value( QString( "%1/dockLayout" ).arg( registryFolderName() ) );
if ( dockState.isValid() )
{
@ -173,7 +179,9 @@ void RiuMainWindowBase::loadWinGeoAndDockToolBarLayout()
if ( !dockingOk )
{
m_dockManager->restoreState( RiuDockWidgetTools::defaultDockState( defaultDockStateNames()[0] ), DOCKSTATE_VERSION );
m_dockManager->restoreState( RiuDockWidgetTools::defaultDockState( defaultDockStateNames()[0] ),
DOCKSTATE_VERSION );
}
}
settings.beginGroup( registryFolderName() );

View File

@ -54,8 +54,9 @@ bool is_region_to_region( const std::string& keyword )
//--------------------------------------------------------------------------------------------------
RiuSummaryQuantityNameInfoProvider* RiuSummaryQuantityNameInfoProvider::instance()
{
static auto* singleton = new RiuSummaryQuantityNameInfoProvider;
return singleton;
static RiuSummaryQuantityNameInfoProvider theInstance;
return &theInstance;
}
//--------------------------------------------------------------------------------------------------

View File

@ -386,7 +386,7 @@ QWidget* PdmUiComboBoxEditor::createEditorWidget( QWidget* parent )
connect( m_comboBox, SIGNAL( activated( int ) ), this, SLOT( slotIndexActivated( int ) ) );
m_autoValueToolButton = new QToolButton();
m_autoValueToolButton = new QToolButton( m_placeholder );
m_autoValueToolButton->setCheckable( true );
m_autoValueToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly );

View File

@ -98,7 +98,7 @@ QWidget* PdmUiLineEditor::createEditorWidget( QWidget* parent )
m_layout->setSpacing( 0 );
m_layout->addWidget( m_lineEdit );
m_autoValueToolButton = new QToolButton();
m_autoValueToolButton = new QToolButton( m_placeholder );
m_autoValueToolButton->setCheckable( true );
m_autoValueToolButton->setToolButtonStyle( Qt::ToolButtonIconOnly );