Skip to content

Commit 4a32a7e

Browse files
Fix race condition caused by improper dbus hack (flameshot-org#4547)
1 parent b5224b5 commit 4a32a7e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/valuehandler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,15 @@ bool Region::check(const QVariant& val)
530530

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

0 commit comments

Comments
 (0)