-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.8
-
None
-
efad13b53 (dev), 9f790c208 (6.9), a25832d19 (tqtc/lts-6.8)
In the Qt Quick Controls example eventcalendar, the EventModel::repopulate() method calls beginResetModel() but may return early without calling endResetModel(), which violates the Qt model-view contract.
File Path: examples/quickcontrols/eventcalendar/eventmodel.cpp
Problematic Code:
void EventModel::repopulate()
{
beginResetModel();
if (!m_eventDatabase || m_date.isNull()) {
m_events.clear();
return; // endResetModel() is never called here
}
m_events = m_eventDatabase->eventsForDate(m_date);
endResetModel();
}
Runtime Output:
When running the example, the following warning is repeatedly printed:
beginResetModel called on EventModel(0x55753b41c540) without calling endResetModel first beginResetModel called on EventModel(0x55753b425280) without calling endResetModel first beginResetModel called on EventModel(0x55753b42e1a0) without calling endResetModel first
candidate fix
--- a/examples/quickcontrols/eventcalendar/eventmodel.cpp
+++ b/examples/quickcontrols/eventcalendar/eventmodel.cpp
@@ -79,6 +79,7 @@ void EventModel::repopulate()
if (!m_eventDatabase || m_date.isNull()) {
m_events.clear();
+ endResetModel();
return;
}
| For Gerrit Dashboard: QTBUG-136947 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 647420,3 | EventCalendar example: balance begin/endResetModel calls | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 647870,2 | EventCalendar example: balance begin/endResetModel calls | 6.9 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 647944,2 | EventCalendar example: balance begin/endResetModel calls | tqtc/lts-6.8 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |