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
+3 -3
View File
@@ -402,7 +402,7 @@ void CaptureDialog::vulkanLayerWarn_mouseClick()
if(admin)
{
RunProcessAsAdmin(qApp->applicationFilePath(),
QStringList() << lit("--install_vulkan_layer") << lit("root"),
QStringList() << lit("--install_vulkan_layer") << lit("root"), this,
[this]() { ui->vulkanLayerWarn->setVisible(false); });
return;
}
@@ -435,7 +435,7 @@ void CaptureDialog::CheckAndroidSetup(QString &filename)
if(!debuggable && !hasroot)
{
// Check failed - set the warning visible
GUIInvoke::call([this]() {
GUIInvoke::call(this, [this]() {
ui->androidScan->setVisible(false);
ui->androidWarn->setVisible(true);
});
@@ -443,7 +443,7 @@ void CaptureDialog::CheckAndroidSetup(QString &filename)
else
{
// Check passed, either app is debuggable or we have root - no warnings needed
GUIInvoke::call([this]() {
GUIInvoke::call(this, [this]() {
ui->androidScan->setVisible(false);
ui->androidWarn->setVisible(false);
});