#1940 Curve Creator : Always recreate curve creator to ensure stable init

This commit is contained in:
Magne Sjaastad 2017-10-02 11:12:31 +02:00
parent fd1b8c83ff
commit eec974c53d
3 changed files with 31 additions and 10 deletions

View File

@ -30,7 +30,7 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreatorDialog::RicSummaryCurveCreatorDialog(QWidget* parent, RicSummaryCurveCreator* summaryCurveCreator)
RicSummaryCurveCreatorDialog::RicSummaryCurveCreatorDialog(QWidget* parent)
: QDialog(parent)
{
m_curveCreatorSplitterUi = new RicSummaryCurveCreatorSplitterUi(this);
@ -41,9 +41,6 @@ RicSummaryCurveCreatorDialog::RicSummaryCurveCreatorDialog(QWidget* parent, RicS
dummy->setContentsMargins(0, 0, 0, 0);
dummy->addWidget(propertyWidget);
m_curveCreatorSplitterUi->setPdmObject(summaryCurveCreator);
m_curveCreatorSplitterUi->updateUi();
setWindowTitle("ResInsight: Plot Editor");
resize(1200, 800);
connect(m_curveCreatorSplitterUi, SIGNAL(signalCloseButtonPressed()), this, SLOT(accept()));
@ -58,6 +55,15 @@ RicSummaryCurveCreatorDialog::~RicSummaryCurveCreatorDialog()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreatorDialog::setCurveCreator(RicSummaryCurveCreator* summaryCurveCreator)
{
m_curveCreatorSplitterUi->setPdmObject(summaryCurveCreator);
m_curveCreatorSplitterUi->updateUi();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -31,9 +31,11 @@ class RicSummaryCurveCreatorDialog : public QDialog
{
Q_OBJECT
public:
RicSummaryCurveCreatorDialog(QWidget* parent, RicSummaryCurveCreator* summaryCurveCreator);
RicSummaryCurveCreatorDialog(QWidget* parent);
~RicSummaryCurveCreatorDialog();
void setCurveCreator(RicSummaryCurveCreator* summaryCurveCreator);
private slots:
void slotDialogFinished();

View File

@ -28,8 +28,8 @@ RicSummaryCurveCreatorFactoryImpl* RicSummaryCurveCreatorFactoryImpl::ms_instanc
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreatorFactoryImpl::RicSummaryCurveCreatorFactoryImpl()
{
m_curveCreator = new RicSummaryCurveCreator();
m_dialogWithSplitter = new RicSummaryCurveCreatorDialog(nullptr, m_curveCreator);
m_dialogWithSplitter = new RicSummaryCurveCreatorDialog(nullptr);
m_curveCreator = nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -48,8 +48,20 @@ RicSummaryCurveCreatorFactoryImpl::~RicSummaryCurveCreatorFactoryImpl()
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreator* RicSummaryCurveCreatorFactoryImpl::curveCreator()
{
if (m_curveCreator == nullptr)
if (m_curveCreator)
{
delete m_curveCreator;
m_curveCreator = nullptr;
}
// Recreate curve creator to make sure initialization is stable
m_curveCreator = new RicSummaryCurveCreator();
if (m_dialogWithSplitter)
{
m_dialogWithSplitter->setCurveCreator(m_curveCreator);
}
return m_curveCreator;
}
@ -59,7 +71,8 @@ RicSummaryCurveCreator* RicSummaryCurveCreatorFactoryImpl::curveCreator()
RicSummaryCurveCreatorDialog* RicSummaryCurveCreatorFactoryImpl::dialog()
{
if (m_dialogWithSplitter == nullptr)
m_dialogWithSplitter = new RicSummaryCurveCreatorDialog(nullptr, curveCreator());
m_dialogWithSplitter = new RicSummaryCurveCreatorDialog(nullptr);
return m_dialogWithSplitter;
}