GUIInvoke takes a QObject* to avoid callbacks after object lifetime

* The GUIInvoke object takes a QObject, and uses QPointer to check that
  it hasn't been deleted when the callback fires. This prevents delayed
  callbacks from executing after the object has been deleted and
  crashing.
* In most cases the pointer is just 'this'.
This commit is contained in:
baldurk
2018-05-08 11:54:34 +01:00
parent c880def5ef
commit 082ab4d75d
25 changed files with 113 additions and 108 deletions
+2 -2
View File
@@ -193,7 +193,7 @@ void CaptureContext::LoadCapture(const rdcstr &captureFile, const rdcstr &origFi
else if(!m_Drawcalls.empty())
SetEventID(viewers, m_Drawcalls.back().eventId, true);
GUIInvoke::blockcall([&viewers]() {
GUIInvoke::blockcall(m_MainWindow, [&viewers]() {
// notify all the registers viewers that a capture has been loaded
for(ICaptureViewer *viewer : viewers)
{
@@ -1062,7 +1062,7 @@ void CaptureContext::AddMessages(const rdcarray<DebugMessage> &msgs)
if(m_DebugMessageView)
{
GUIInvoke::call([this]() { m_DebugMessageView->RefreshMessageList(); });
GUIInvoke::call(m_DebugMessageView, [this]() { m_DebugMessageView->RefreshMessageList(); });
}
}