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,8 +16,8 @@
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
#include "pintool.h"
#include "src/core/qguiappcurrentscreen.h"
#include "src/tools/pin/pinwidget.h"
#include <QGuiApplication>
#include <QScreen>
PinTool::PinTool(QObject* parent)
@@ -54,7 +54,7 @@ QWidget* PinTool::widget()
qreal devicePixelRatio = 1;
#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();
if (currentScreen) {
devicePixelRatio = currentScreen->devicePixelRatio();
}