diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index d31e486e1..03d6017b8 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -1848,10 +1848,21 @@ An interface implemented by any object wanting to be notified of capture events. )"); struct ICaptureViewer { - DOCUMENT("Called whenever a capture is opened."); + DOCUMENT(R"(Called immediately after a capture is opened, while the capture is open. + +Although this allows access to capture information, this callback will be called while the UI is also +populating as well (the order for capture viewers including UI panels is undefined) so it is recommended +not to do much in this callback beyond any initialisation and access to underlying capture information. +)"); virtual void OnCaptureLoaded() = 0; - DOCUMENT("Called whenever a capture is closed."); + DOCUMENT(R"(Called immediately before a capture is closed, while the capture is open. + +As with :meth:`OnCaptureLoaded` this will be called while the UI is closing down so it is strongly +recommended that you do no work apart from releasing resources and clearing any caches in this function. +If you want to run code after the capture has closed you can issue a delayed callback, which will be +guaranteed not to be called until after the capture is completely closed. +)"); virtual void OnCaptureClosed() = 0; DOCUMENT(R"(Called whenever the current selected event changes. This is distinct from the actual diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index fd2dee46a..a35223356 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -225,7 +225,7 @@ struct EventItemModel : public QAbstractItemModel .arg(paramcol.blue(), 2, 16, QLatin1Char('0')); } - void ResetModel() + void ResetModel(bool closing) { emit beginResetModel(); emit endResetModel(); @@ -238,7 +238,7 @@ struct EventItemModel : public QAbstractItemModel m_Chunks.clear(); m_Times.clear(); - if(!m_Ctx.CurRootActions().empty()) + if(!closing && !m_Ctx.CurRootActions().empty()) m_Nodes[0] = CreateActionNode(NULL); m_CurrentEID = createIndex(0, 0, TagCaptureStart); @@ -250,7 +250,8 @@ struct EventItemModel : public QAbstractItemModel m_FindString.clear(); m_FindEIDSearch = false; - RefreshCache(); + if(!closing) + RefreshCache(); } void RefreshCache() @@ -4058,7 +4059,7 @@ void EventBrowser::OnCaptureLoaded() // older Qt versions lose all the sections when a model resets even if the sections don't change. // Manually save/restore them QVariant p = persistData(); - m_Model->ResetModel(); + m_Model->ResetModel(false); setPersistData(p); // expand the root frame node @@ -4101,7 +4102,7 @@ void EventBrowser::OnCaptureClosed() // older Qt versions lose all the sections when a model resets even if the sections don't change. // Manually save/restore them QVariant p = persistData(); - m_Model->ResetModel(); + m_Model->ResetModel(true); setPersistData(p); ui->find->setEnabled(false);