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
@@ -120,7 +120,7 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventId)
m_Ctx.Replay().AsyncInvoke([this, offs, size, wasEmpty](IReplayController *r) {
bytebuf data = r->GetBufferData(m_cbuffer, offs, size);
rdcarray<ShaderVariable> vars = applyFormatOverride(data);
GUIInvoke::call([this, vars, wasEmpty] {
GUIInvoke::call(this, [this, vars, wasEmpty] {
setVariables(vars);
if(wasEmpty)
{
@@ -135,7 +135,7 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventId)
m_Ctx.Replay().AsyncInvoke([this, entryPoint, offs, wasEmpty](IReplayController *r) {
rdcarray<ShaderVariable> vars = r->GetCBufferVariableContents(
m_shader, entryPoint.toUtf8().data(), m_slot, m_cbuffer, offs);
GUIInvoke::call([this, vars, wasEmpty] {
GUIInvoke::call(this, [this, vars, wasEmpty] {
setVariables(vars);
if(wasEmpty)
{