QmlDesigner: Fix crash when switching to first .ui.qml file

if Qt Creator is already in Design mode.

QmlDesignerPlugin::showDesigner() was only called on a switch to Design
mode while the editor is a .ui.qml file. So it wasn't called when opening
a .ui file in Design mode and then switching to a .ui.qml file. But
showDesigner() creates the QmlDesigner widgets, so it must be called.

Fixes: QTCREATORBUG-32854
Change-Id: I02a498ce00fc1afdee900752ade7af6c62b787b7
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Eike Ziller
2025-04-23 16:31:05 +02:00
parent a2fda5c048
commit cf83c0b651
3 changed files with 16 additions and 2 deletions

View File

@@ -651,6 +651,11 @@ void DesignModeWidget::setMinimumSizeHintFromContentMinimumSize(bool value)
dockContainer->layout()->update();
}
bool DesignModeWidget::isInitialized() const
{
return m_initStatus == Initialized;
}
void DesignModeWidget::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();

View File

@@ -75,6 +75,8 @@ public:
void setMinimumSizeHintFromContentMinimumSize(bool value);
bool isInitialized() const;
signals:
void navigationHistoryChanged();
void initialized();

View File

@@ -529,8 +529,15 @@ void QmlDesignerPlugin::hideDesigner()
void QmlDesignerPlugin::changeEditor()
{
if (d->mainWidget.isInitialized()) {
// showDesigner was already already called
clearDesigner();
setupDesigner();
} else {
// we are already in Design mode, but showDesigner wasn't called yet,
// so we need to call that to set up the widgets
showDesigner();
}
}
void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode()