Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,9 @@ int main(int argc, char* argv[])
req.addSaveTask();
}
}
return requestCaptureAndWait(req);
int guiExitCode = requestCaptureAndWait(req);
delete qApp;
return guiExitCode;
} else if (parser.isSet(fullArgument)) { // FULL
reinitializeAsQApplication(argc, argv, translator, qtTranslator);

Expand Down Expand Up @@ -564,7 +566,11 @@ int main(int argc, char* argv[])
if (!clipboard && path.isEmpty() && !raw && !upload) {
req.addSaveTask();
}
return requestCaptureAndWait(req);
{
int fullExitCode = requestCaptureAndWait(req);
delete qApp;
return fullExitCode;
}
} else if (parser.isSet(screenArgument)) { // SCREEN
reinitializeAsQApplication(argc, argv, translator, qtTranslator);

Expand Down Expand Up @@ -614,7 +620,11 @@ int main(int argc, char* argv[])
req.addSaveTask();
}

return requestCaptureAndWait(req);
{
int screenExitCode = requestCaptureAndWait(req);
delete qApp;
return screenExitCode;
}
} else if (parser.isSet(configArgument)) { // CONFIG
bool autostart = parser.isSet(autostartOption);
bool notification = parser.isSet(notificationOption);
Expand Down Expand Up @@ -680,6 +690,6 @@ int main(int argc, char* argv[])
}
}
finish:

delete qApp;
return 0;
}
8 changes: 6 additions & 2 deletions src/utils/valuehandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,15 @@ bool Region::check(const QVariant& val)

QVariant Region::process(const QVariant& val)
{
// FIXME: This is temporary, just before D-Bus is removed
// Create a temporary QApplication if there is no global Qt application
// instance at all. Creating one while a QCoreApplication already exists
// is forbidden by Qt: the second constructor aborts early, but its
// destructor still runs and corrupts global state (e.g. Wayland
// connections), causing subsequent portal calls to hang.
auto argv = std::make_unique<char*[]>(1);
auto argc = std::make_unique<int>(0);
std::unique_ptr<QApplication> tempApp;
if (QGuiApplication::screens().empty()) {
if (!QCoreApplication::instance()) {
tempApp = std::make_unique<QApplication>(*argc, argv.get());
}

Expand Down
Loading