Fix - MacOS - get currentScreen on the edge bottom and right returns nullptr and application crashes

(cherry picked from commit 01ae74fbed34849db485db53ffbdf4a938ebea8e)
This commit is contained in:
Yuriy Puchkov
2021-02-08 19:19:51 +02:00
parent 0425be7a44
commit dc7f62ab8d
12 changed files with 144 additions and 43 deletions

View File

@@ -16,6 +16,7 @@
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
#include "screengrabber.h"
#include "src/core/qguiappcurrentscreen.h"
#include "src/utils/filenamehandler.h"
#include "src/utils/systemnotification.h"
#include <QApplication>
@@ -40,7 +41,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
ok = true;
#if (defined(Q_OS_MAC) || defined(Q_OS_MAC64) || defined(Q_OS_MACOS) || \
defined(Q_OS_MACX))
QScreen* currentScreen = QGuiApplication::screenAt(QCursor::pos());
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
QPixmap screenPixmap(
currentScreen->grabWindow(QApplication::desktop()->winId(),
currentScreen->geometry().x(),