forked from qt-creator/qt-creator
QmlDesigner: Fix targetTexture getting invalidated after menu open
In some situation the targetTexture gets invalidated after the context menu opens. This is likely related to texture model changing the selection, but the exact cause is not known. Worked around the issue by already storing the texture internal id at menu open. Fixes: QDS-13461 Change-Id: Ib0e29a59b22ab9ccf244de3dcd4e7d2d1ee0fd7b Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -10,16 +10,17 @@ import MaterialBrowserBackend
|
||||
StudioControls.Menu {
|
||||
id: root
|
||||
|
||||
property var targetTexture: null
|
||||
property int copiedTextureInternalId: -1
|
||||
property int textureInternalId: -1
|
||||
|
||||
property var materialBrowserTexturesModel: MaterialBrowserBackend.materialBrowserTexturesModel
|
||||
|
||||
function popupMenu(targetTexture = null)
|
||||
{
|
||||
this.targetTexture = targetTexture
|
||||
root.textureInternalId = targetTexture ? targetTexture.textureInternalId : -1
|
||||
|
||||
materialBrowserTexturesModel.updateSceneEnvState()
|
||||
materialBrowserTexturesModel.updateModelSelectionState()
|
||||
|
||||
popup()
|
||||
}
|
||||
|
||||
@@ -27,33 +28,33 @@ StudioControls.Menu {
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Apply to selected model")
|
||||
enabled: root.targetTexture && materialBrowserTexturesModel.hasSingleModelSelection
|
||||
onTriggered: materialBrowserTexturesModel.applyToSelectedModel(root.targetTexture.textureInternalId)
|
||||
enabled: root.textureInternalId >= 0 && materialBrowserTexturesModel.hasSingleModelSelection
|
||||
onTriggered: materialBrowserTexturesModel.applyToSelectedModel(root.textureInternalId)
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Apply to selected material")
|
||||
enabled: root.targetTexture && MaterialBrowserBackend.materialBrowserModel.selectedIndex >= 0
|
||||
onTriggered: materialBrowserTexturesModel.applyToSelectedMaterial(root.targetTexture.textureInternalId)
|
||||
enabled: root.textureInternalId >= 0 && MaterialBrowserBackend.materialBrowserModel.selectedIndex >= 0
|
||||
onTriggered: materialBrowserTexturesModel.applyToSelectedMaterial(root.textureInternalId)
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Apply as light probe")
|
||||
enabled: root.targetTexture && materialBrowserTexturesModel.hasSceneEnv
|
||||
onTriggered: materialBrowserTexturesModel.applyAsLightProbe(root.targetTexture.textureInternalId)
|
||||
enabled: root.textureInternalId >= 0 && materialBrowserTexturesModel.hasSceneEnv
|
||||
onTriggered: materialBrowserTexturesModel.applyAsLightProbe(root.textureInternalId)
|
||||
}
|
||||
|
||||
StudioControls.MenuSeparator {}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Duplicate")
|
||||
enabled: root.targetTexture
|
||||
enabled: root.textureInternalId >= 0
|
||||
onTriggered: materialBrowserTexturesModel.duplicateTexture(materialBrowserTexturesModel.selectedIndex)
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Delete")
|
||||
enabled: root.targetTexture
|
||||
enabled: root.textureInternalId >= 0
|
||||
onTriggered: materialBrowserTexturesModel.deleteTexture(materialBrowserTexturesModel.selectedIndex)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user