Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-136947

EventModel::repopulate() missing endResetModel() on early return in eventcalendar example

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.8
    • Examples and Demos
    • 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;
           }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            pengzh Peng Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes