Skip to content

Commit 3051c63

Browse files
committed
fix: add null check for QScreen in resizeByCurrentScreen
Add null pointer check for cursorScreen and quakeScreen to prevent potential crash when screenAt() returns nullptr. Log: 修复resizeByCurrentScreen中QScreen空指针检查 Influence: 防止在screenAt返回空指针时崩溃
1 parent 57b7c43 commit 3051c63

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main/mainwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3513,7 +3513,7 @@ void QuakeWindow::resizeByCurrentScreen(bool force)
35133513
QPoint cursorPoint = QCursor::pos();
35143514
const QScreen *quakeScreen = QGuiApplication::screenAt(pos());
35153515
const QScreen *cursorScreen = QGuiApplication::screenAt(cursorPoint);
3516-
if (force || (!isVisible() && quakeScreen->serialNumber() != cursorScreen->serialNumber())) {
3516+
if (cursorScreen && (force || (!isVisible() && quakeScreen && quakeScreen->serialNumber() != cursorScreen->serialNumber()))) {
35173517
int windowWidth = cursorScreen->geometry().width();
35183518
move(cursorScreen->geometry().topLeft());
35193519
setFixedWidth(windowWidth);

0 commit comments

Comments
 (0)