Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8
-
None
Description
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; }