Commit 1e069f19 authored by Dimitris Kardarakos's avatar Dimitris Kardarakos

Ensure object existence before property access

When a property of an object is read or set, ensure that the object in
concern does still exist
parent 4c0b40e2
Pipeline #20330 passed with stage
in 6 minutes and 31 seconds
......@@ -14,8 +14,7 @@ Kirigami.Action {
signal deleteCalendar
checked: (text == _calindoriConfig.activeCalendar)
visible: _calindoriConfig.activeCalendar != text
visible: _calindoriConfig != null ? (_calindoriConfig.activeCalendar != text) : false
Kirigami.Action {
text: "Activate calendar"
......
......@@ -171,10 +171,10 @@ Kirigami.GlobalDrawer {
CalendarEditor {
onCalendarAdded: {
root.pageStack.pop(calendarEditor);
root.pageStack.push(monthView);
pageStack.pop(calendarEditor);
pageStack.push(monthView);
}
onCalendarAddCanceled: root.pageStack.pop(calendarEditor)
onCalendarAddCanceled: pageStack.pop(calendarEditor)
}
}
......
......@@ -15,7 +15,7 @@ Kirigami.Card {
property var dataModel
banner.title: dataModel.summary
banner.title: dataModel && dataModel.summary
banner.titleLevel: 3
contentItem: Column {
......@@ -34,21 +34,21 @@ Kirigami.Card {
}
Controls2.Label {
property bool sameEndStart : dataModel.dtstart && !isNaN(dataModel.dtstart) && dataModel.dtend && !isNaN(dataModel.dtend) && dataModel.dtstart.toLocaleString(Qt.locale(), "dd.MM.yyyy") == dataModel.dtend.toLocaleString(Qt.locale(), "dd.MM.yyyy")
property string timeFormat: dataModel.allday ? "" : "hh:mm"
property string dateFormat: dataModel.allday ? "ddd d MMM yyyy" : "ddd d MMM yyyy hh:mm"
property string separator: dataModel.allday ? "" : " - "
property bool sameEndStart: dataModel && dataModel.dtstart && !isNaN(dataModel.dtstart) && dataModel.dtend && !isNaN(dataModel.dtend) && dataModel.dtstart.toLocaleString(Qt.locale(), "dd.MM.yyyy") == dataModel.dtend.toLocaleString(Qt.locale(), "dd.MM.yyyy")
property string timeFormat: dataModel && (dataModel.allday ? "" : "hh:mm")
property string dateFormat: dataModel && (dataModel.allday ? "ddd d MMM yyyy" : "ddd d MMM yyyy hh:mm")
property string separator: dataModel && (dataModel.allday ? "" : " - ")
wrapMode: Text.WordWrap
text: ((dataModel.dtstart && !isNaN(dataModel.dtstart)) ? dataModel.dtstart.toLocaleString(Qt.locale(), dateFormat ) : "") +
(dataModel.dtend && !isNaN(dataModel.dtend) ? separator +
text: ((dataModel && dataModel.dtstart && !isNaN(dataModel.dtstart)) ? dataModel.dtstart.toLocaleString(Qt.locale(), dateFormat ) : "") +
(dataModel && dataModel.dtend && !isNaN(dataModel.dtend) ? separator +
dataModel.dtend.toLocaleString(Qt.locale(), sameEndStart ? timeFormat : dateFormat ) : "")
Layout.fillWidth: true
}
}
RowLayout {
visible: dataModel.location != ""
visible: dataModel && (dataModel.location != "")
width: cardDelegate.availableWidth
spacing: Kirigami.Units.smallSpacing
......@@ -60,13 +60,13 @@ Kirigami.Card {
Controls2.Label {
wrapMode: Text.WordWrap
text: dataModel.location
text: dataModel && dataModel.location
Layout.fillWidth: true
}
}
RowLayout {
visible: dataModel.isRepeating
visible: dataModel && dataModel.isRepeating
width: cardDelegate.availableWidth
spacing: Kirigami.Units.smallSpacing
......@@ -78,16 +78,16 @@ Kirigami.Card {
Controls2.Label {
wrapMode: Text.WordWrap
text: _repeatModel.repeatDescription(dataModel.repeatType, dataModel.repeatEvery, dataModel.repeatStopAfter)
text: dataModel && _repeatModel.repeatDescription(dataModel.repeatType, dataModel.repeatEvery, dataModel.repeatStopAfter)
Layout.fillWidth: true
}
}
Controls2.Label {
visible: dataModel.description != ""
visible: dataModel && (dataModel.description != "")
width: cardDelegate.availableWidth
wrapMode: Text.WordWrap
text: dataModel.description
text: dataModel && dataModel.description
}
}
}
......@@ -15,17 +15,17 @@ Kirigami.Card {
property var dataModel
banner.title: dataModel.summary
banner.title: dataModel && dataModel.summary
banner.titleLevel: 3
contentItem: Column {
enabled: !dataModel.completed
enabled: dataModel && !dataModel.completed
spacing: Kirigami.Units.largeSpacing
topPadding: 0
bottomPadding: Kirigami.Units.largeSpacing
Row {
visible: dataModel.dtstart && !isNaN(dataModel.dtstart)
visible: dataModel && dataModel.dtstart && !isNaN(dataModel.dtstart)
width: cardDelegate.availableWidth
spacing: Kirigami.Units.smallSpacing
......@@ -37,12 +37,12 @@ Kirigami.Card {
Controls2.Label {
wrapMode: Text.WordWrap
text: (dataModel.dtstart && !isNaN(dataModel.dtstart)) ? dataModel.dtstart.toLocaleString(Qt.locale(), dataModel.allday ? "ddd d MMM yyyy" : "ddd d MMM yyyy hh:mm" ) : ""
text: dataModel && ((dataModel.dtstart && !isNaN(dataModel.dtstart)) ? dataModel.dtstart.toLocaleString(Qt.locale(), dataModel.allday ? "ddd d MMM yyyy" : "ddd d MMM yyyy hh:mm" ) : "")
}
}
Row {
visible: dataModel.location != ""
visible: dataModel && (dataModel.location != "")
width: cardDelegate.availableWidth
spacing: Kirigami.Units.smallSpacing
......@@ -54,14 +54,14 @@ Kirigami.Card {
Controls2.Label {
wrapMode: Text.WordWrap
text: dataModel.location
text: dataModel && dataModel.location
}
}
Controls2.Label {
width: cardDelegate.availableWidth
wrapMode: Text.WordWrap
text: dataModel.description
text: dataModel && dataModel.description
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment