mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
#14903: Avoid duplicate dock window ids for copied plots
Copies and plots created from templates kept the source DockWindowId. The dock manager identifies dock widgets by name, so the earlier dock widget was deleted on dock state restore, leaving a dangling pointer that crashed in setActiveViewer. - Do not copy DockWindowId; copies get a new id - Assign a new id if a dock widget with the same name exists - Use QPointer for the dock widget
This commit is contained in:
1 parent
24e5d2b441
commit
9ac6ad3bec
5 files changed
+53
-4
No files matched your search
@@ -145,6 +145,14 @@ void RimDockWindowController::updateViewerWidget()
|
||||
return;
|
||||
}
|
||||
|
||||
// The dock manager identifies dock widgets by name. A duplicate name (e.g. from a project saved with
|
||||
// copied views) would unregister the existing dock widget, which is then deleted on next dock state restore.
|
||||
if ( auto existing = mainWindow->dockManager()->findDockWidget( viewPdmObject()->dockWindowName() );
|
||||
existing && existing != dockWidget )
|
||||
{
|
||||
viewPdmObject()->resetDockWindowId();
|
||||
}
|
||||
|
||||
dockWidget->setWidget( viewWidget );
|
||||
dockWidget->setObjectName( viewPdmObject()->dockWindowName() );
|
||||
viewWidget->setObjectName( viewPdmObject()->dockWindowName() );
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiToolButtonEditor.h"
|
||||
|
||||
#include "DockWidget.h"
|
||||
|
||||
#include <QPaintDevice>
|
||||
#include <QRegularExpression>
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ RimViewWindow::RimViewWindow()
|
||||
|
||||
CAF_PDM_InitField( &m_dockWindowId, "DockWindowId", QString(), "Dock Window Id" );
|
||||
m_dockWindowId.uiCapability()->setUiHidden( true );
|
||||
// The dock id must be unique, as the dock manager identifies dock widgets by name. Copies (including plots created
|
||||
// from templates) get a new id.
|
||||
m_dockWindowId.xmlCapability()->setCopyable( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
class QImage;
|
||||
class RimDockWindowController;
|
||||
|
||||
@@ -117,8 +119,8 @@ private:
|
||||
protected:
|
||||
caf::PdmChildField<RimDockWindowController*> m_windowController;
|
||||
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
ads::CDockWidget* m_dockWidget;
|
||||
caf::PdmField<QString> m_dockWindowId;
|
||||
bool m_isActiveViewer;
|
||||
caf::PdmField<bool> m_showWindow;
|
||||
QPointer<ads::CDockWidget> m_dockWidget;
|
||||
caf::PdmField<QString> m_dockWindowId;
|
||||
bool m_isActiveViewer;
|
||||
};
|
||||
Reference in new issue
Block a user