diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 196e878932..8332466046 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -416,6 +416,12 @@ void Flameshot::exportCapture(QPixmap capture, if (!(tasks & CR::UPLOAD)) { emit captureTaken(capture); } + // hacks: close a window to trigger qt's quitOnLastWindowClose + // if not create tmp_window and close, the `flameshot gui` won't exit after + // click copy button + QWidget* tmp = new QWidget(); + tmp->show(); + tmp->close(); } // STATIC ATTRIBUTES diff --git a/src/main.cpp b/src/main.cpp index 1d4ddd1b03..ee5f1951e0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,12 +49,14 @@ void requestCaptureAndWait(const CaptureRequest& req) { Flameshot* flameshot = Flameshot::instance(); flameshot->requestCapture(req); - QObject::connect(flameshot, &Flameshot::captureTaken, [&](QPixmap) { - // Only useful on MacOS because each instance hosts its own widgets +#if defined(Q_OS_MACOS) + // Only useful on MacOS because each instance hosts its own widgets + QObject::connect(flameshot, &Flameshot::captureTaken, [&](const QPixmap&) { if (!FlameshotDaemon::isThisInstanceHostingWidgets()) { qApp->exit(0); } }); +#endif QObject::connect(flameshot, &Flameshot::captureFailed, []() { AbstractLogger::info() << "Screenshot aborted."; qApp->exit(1);