on xenial help sign in
MenuItemFactory: prevent infinite loops on model activation causing calendar day changes
22568ddMarco Trevisan (Treviño)
qml/Panel/Indicators/MenuItemFactory.qml+19−6
@@ -505,25 +505,38 @@ Item {
505 id: calendarMenu
505 id: calendarMenu
506
506
507 Menus.CalendarMenu {
507 Menus.CalendarMenu {
508+ id: calendarItem
508 objectName: "calendarMenu"
509 objectName: "calendarMenu"
509 focus: true
510 focus: true
510
511
511 property QtObject menuData: null
512 property QtObject menuData: null
512 property var menuModel: menuFactory.menuModel
513 property var menuModel: menuFactory.menuModel
513 property var actionState: menuData && menuData.actionState || null
514 property var actionState: menuData && menuData.actionState || null
514− property int calendarDay: getExtendedProperty(actionState, "calendar-day", 0) * 1000
515+ property real calendarDay: getExtendedProperty(actionState, "calendar-day", 0)
515 property int menuIndex: -1
516 property int menuIndex: -1
516
517
517 showWeekNumbers: getExtendedProperty(actionState, "show-week-numbers", false)
518 showWeekNumbers: getExtendedProperty(actionState, "show-week-numbers", false)
518 eventDays: getExtendedProperty(actionState, "appointment-days", [])
519 eventDays: getExtendedProperty(actionState, "appointment-days", [])
519
520
520− Binding on currentDate {
521+ onCalendarDayChanged: {
521− when: calendarDay > 0
522+ if (calendarDay > 0) {
523+ // This would trigger a selectionDateChanged signal, thus
524+ // we've to avoid that the subsequent model activation
525+ // would cause an infinite loop
526+ modelUpdateConnections.enabled = false
522− value: new Date(calendarDay)
527+ currentDate = new Date(calendarDay * 1000)
528+ modelUpdateConnections.enabled = true
529+ }
523 }
530 }
524
531
532+ Connections {
533+ id: modelUpdateConnections
534+ property bool enabled: true
535+ target: (enabled && calendarItem.visible) ? calendarItem : null
536+
525− onSelectedDateChanged: {
537+ onSelectedDateChanged: {
526− menuModel.activate(menuIndex, selectedDate.getTime() / 1000 | 0)
538+ menuModel.activate(menuIndex, selectedDate.getTime() / 1000 | 0)
539+ }
527 }
540 }
528 }
541 }
529 }
542 }