forked from qt-creator/qt-creator
QmlDesigner: Fix some Qml null warnings
Remove some warnings that appear on launch and shut down Change-Id: I0eb58eadd9e975f0cfc7ec74636f540c26042589 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -9,20 +9,11 @@ QtObject {
|
||||
|
||||
property variant backendValue
|
||||
property color textColor: StudioTheme.Values.themeTextColor
|
||||
property variant valueFromBackend: root.backendValue === undefined ? 0 : root.backendValue.value
|
||||
property variant valueFromBackend: root.backendValue?.value ?? 0
|
||||
property bool baseStateFlag: isBaseState
|
||||
property bool isInModel: {
|
||||
if (root.backendValue !== undefined && root.backendValue.isInModel !== undefined)
|
||||
return root.backendValue.isInModel
|
||||
property bool isInModel: root.backendValue?.isInModel ?? false
|
||||
property bool isInSubState: root.backendValue?.isInSubState ?? false
|
||||
|
||||
return false
|
||||
}
|
||||
property bool isInSubState: {
|
||||
if (root.backendValue !== undefined && root.backendValue.isInSubState !== undefined)
|
||||
return root.backendValue.isInSubState
|
||||
|
||||
return false
|
||||
}
|
||||
property bool highlight: root.textColor === root.__changedTextColor
|
||||
property bool errorState: false
|
||||
|
||||
@@ -38,7 +29,7 @@ QtObject {
|
||||
onErrorStateChanged: root.evaluate()
|
||||
|
||||
function evaluate() {
|
||||
if (root.backendValue === undefined)
|
||||
if (!root.backendValue)
|
||||
return
|
||||
|
||||
if (root.errorState) {
|
||||
@@ -47,15 +38,11 @@ QtObject {
|
||||
}
|
||||
|
||||
if (root.baseStateFlag) {
|
||||
if (root.backendValue.isInModel)
|
||||
root.textColor = root.__changedTextColor
|
||||
else
|
||||
root.textColor = root.__defaultTextColor
|
||||
root.textColor = root.backendValue.isInModel ? root.__changedTextColor
|
||||
: root.__defaultTextColor
|
||||
} else {
|
||||
if (root.backendValue.isInSubState)
|
||||
root.textColor = StudioTheme.Values.themeChangedStateText
|
||||
else
|
||||
root.textColor = root.__defaultTextColor
|
||||
root.textColor = root.backendValue.isInSubState ? StudioTheme.Values.themeChangedStateText
|
||||
: root.__defaultTextColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ StudioControls.ComboBox {
|
||||
|
||||
onModelChanged: colorLogic.invalidate()
|
||||
|
||||
hasActiveDrag: comboBox.backendValue !== undefined && comboBox.backendValue.hasActiveDrag
|
||||
hasActiveDrag: comboBox.backendValue?.hasActiveDrag ?? false
|
||||
|
||||
// This is available in all editors.
|
||||
|
||||
@@ -120,7 +120,7 @@ StudioControls.ComboBox {
|
||||
break
|
||||
case ComboBox.ValueType.Enum:
|
||||
default:
|
||||
if (comboBox.backendValue === undefined)
|
||||
if (!comboBox.backendValue)
|
||||
break
|
||||
|
||||
var enumString = comboBox.backendValue.enumeration
|
||||
|
@@ -11,18 +11,8 @@ Item {
|
||||
id: extendedFunctionButton
|
||||
|
||||
property variant backendValue
|
||||
property bool isBoundBackend: {
|
||||
if (backendValue !== undefined && backendValue.isBound !== undefined)
|
||||
return backendValue.isBound
|
||||
|
||||
return false
|
||||
}
|
||||
property string backendExpression: {
|
||||
if (backendValue !== undefined && backendValue.expression !== undefined)
|
||||
return backendValue.expression
|
||||
|
||||
return ""
|
||||
}
|
||||
property bool isBoundBackend: backendValue?.isBound ?? false
|
||||
property string backendExpression: backendValue?.expression ?? ""
|
||||
|
||||
property string glyph: StudioTheme.Constants.actionIcon
|
||||
property string color: StudioTheme.Values.themeTextColor
|
||||
@@ -38,7 +28,7 @@ Item {
|
||||
|
||||
function setIcon() {
|
||||
extendedFunctionButton.color = StudioTheme.Values.themeTextColor
|
||||
if (backendValue === undefined) {
|
||||
if (!backendValue) {
|
||||
extendedFunctionButton.glyph = StudioTheme.Constants.actionIcon
|
||||
} else if (backendValue.isBound) {
|
||||
if (backendValue.isTranslated) {
|
||||
@@ -49,12 +39,8 @@ Item {
|
||||
extendedFunctionButton.color = StudioTheme.Values.themeInteraction
|
||||
}
|
||||
} else {
|
||||
if (backendValue.complexNode !== undefined
|
||||
&& backendValue.complexNode.exists) {
|
||||
|
||||
} else {
|
||||
if (!backendValue.complexNode || !backendValue.complexNode.exists)
|
||||
extendedFunctionButton.glyph = StudioTheme.Constants.actionIcon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +63,8 @@ Item {
|
||||
id: menu
|
||||
|
||||
onAboutToShow: {
|
||||
exportMenuItem.checked = backendValue.hasPropertyAlias()
|
||||
exportMenuItem.enabled = !backendValue.isAttachedProperty()
|
||||
exportMenuItem.checked = backendValue?.hasPropertyAlias() ?? false
|
||||
exportMenuItem.enabled = !(backendValue?.isAttachedProperty() ?? false)
|
||||
extendedFunctionButton.menuVisible = true
|
||||
}
|
||||
onAboutToHide: extendedFunctionButton.menuVisible = false
|
||||
|
@@ -111,8 +111,7 @@ StudioControls.TextField {
|
||||
lineEdit.__dirty = false
|
||||
}
|
||||
|
||||
property bool isTranslated: colorLogic.backendValue === undefined ? false
|
||||
: colorLogic.backendValue.isTranslated
|
||||
property bool isTranslated: colorLogic.backendValue?.isTranslated ?? false
|
||||
|
||||
translationIndicator.onClicked: {
|
||||
if (lineEdit.translationIndicator.checked) {
|
||||
@@ -124,19 +123,12 @@ StudioControls.TextField {
|
||||
colorLogic.evaluate()
|
||||
}
|
||||
|
||||
property variant backendValueValueInternal: lineEdit.backendValue === undefined ? 0
|
||||
: lineEdit.backendValue.value
|
||||
property variant backendValueValueInternal: lineEdit.backendValue?.value ?? 0
|
||||
onBackendValueValueInternalChanged: {
|
||||
if (lineEdit.backendValue === undefined)
|
||||
lineEdit.translationIndicator.checked = false
|
||||
else
|
||||
lineEdit.translationIndicator.checked = lineEdit.backendValue.isTranslated
|
||||
lineEdit.translationIndicator.checked = lineEdit.backendValue?.isTranslated ?? false
|
||||
}
|
||||
|
||||
onIsTranslatedChanged: {
|
||||
if (lineEdit.backendValue === undefined)
|
||||
lineEdit.translationIndicator.checked = false
|
||||
else
|
||||
lineEdit.translationIndicator.checked = lineEdit.backendValue.isTranslated
|
||||
lineEdit.translationIndicator.checked = lineEdit.backendValue?.isTranslated ?? false
|
||||
}
|
||||
}
|
||||
|
@@ -31,18 +31,18 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
spinBox.enabled = backendValue === undefined ? false : !isBlocked(backendValue.name)
|
||||
spinBox.enabled = backendValue ? !isBlocked(backendValue.name) : false
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: modelNodeBackend
|
||||
function onSelectionChanged() {
|
||||
spinBox.enabled = backendValue === undefined ? false : !isBlocked(backendValue.name)
|
||||
spinBox.enabled = backendValue ? !isBlocked(backendValue.name) : false
|
||||
}
|
||||
}
|
||||
|
||||
onBackendValueChanged: {
|
||||
spinBox.enabled = backendValue === undefined ? false : !isBlocked(backendValue.name)
|
||||
spinBox.enabled = backendValue ? !isBlocked(backendValue.name) : false
|
||||
}
|
||||
|
||||
StudioControls.RealSpinBox {
|
||||
|
@@ -88,7 +88,7 @@ Row {
|
||||
ToolTip {
|
||||
id: toolTip
|
||||
visible: comboBox.hover && toolTip.text !== ""
|
||||
text: root.backendValue.valueToString
|
||||
text: root.backendValue?.valueToString ?? ""
|
||||
delay: StudioTheme.Values.toolTipDelay
|
||||
|
||||
background: Rectangle {
|
||||
|
Reference in New Issue
Block a user