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
@@ -312,7 +312,7 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
rdcstr disasm = r->DisassembleShader(m_Pipeline, m_ShaderDetails, "");
GUIInvoke::call([this, targets, disasm]() {
GUIInvoke::call(this, [this, targets, disasm]() {
QStringList targetNames;
for(const rdcstr &t : targets)
{
@@ -909,7 +909,7 @@ void ShaderViewer::disassemble_typeChanged(int index)
m_Ctx.Replay().AsyncInvoke([this, target](IReplayController *r) {
rdcstr disasm = r->DisassembleShader(m_Pipeline, m_ShaderDetails, target.data());
GUIInvoke::call([this, disasm]() {
GUIInvoke::call(this, [this, disasm]() {
m_DisassemblyView->setReadOnly(false);
m_DisassemblyView->setText(disasm.c_str());
m_DisassemblyView->setReadOnly(true);