Skip to content

Commit e72ffcb

Browse files
committed
fix: EPMViewer.exe opens entirely off-screen (stuck in taskbar, blank preview)
EPMViewerWindow restored its saved window position via move(pos) with no validation that the position is still within any currently connected screen's bounds. A position saved from a previous monitor configuration (e.g. a since-disconnected second monitor to the left of the primary, x=-1353) is now far outside the single remaining screen (0,0 to 1536,864). The window still launches and runs (visible in the taskbar, non-zero memory/CPU), but renders entirely off-screen, so the taskbar thumbnail preview is blank and nothing is visible on any monitor. Fixed by checking the restored QRect(pos, size) against QGuiApplication::screens() before calling move(); if it doesn't intersect any current screen, fall back to the default (40, 40) position instead.
1 parent f69898a commit e72ffcb

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/applications/epm-viewer/EPMViewerWindow.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
#include <QColorDialog>
3131
#include <QFileDialog>
3232
#include <QFileInfo>
33+
#include <QGuiApplication>
3334
#include <QMenu>
3435
#include <QMenuBar>
3536
#include <QMessageBox>
3637
#include <QMetaMethod>
3738
#include <QProcess>
3839
#include <QResizeEvent>
40+
#include <QScreen>
3941
#include <QSet>
4042
#include <QStatusBar>
4143
#include <QTimer>
@@ -132,9 +134,31 @@ EPMViewerWindow::EPMViewerWindow
132134
settings.beginGroup("EPMViewerWindow");
133135

134136
QPoint pos = settings.value("pos", QPoint(40, 40)).toPoint();
135-
move(pos);
136-
137137
QSize size = settings.value("size", QSize(1200, 800)).toSize();
138+
139+
// Validate the saved position against currently connected screens before
140+
// restoring it. A position saved from a monitor configuration that no
141+
// longer exists (e.g. a since-disconnected second monitor, or a
142+
// different machine's screen layout carried over via a settings file)
143+
// can be far outside all current screens' bounds. QWidget::move() does
144+
// no such validation, so the window would end up entirely off-screen:
145+
// it still runs (visible in the taskbar / Alt-Tab), but nothing is
146+
// visible on any monitor and the taskbar thumbnail preview is blank.
147+
QRect windowRect(pos, size);
148+
bool visibleOnAnyScreen = false;
149+
for (const auto& screen: QGuiApplication::screens())
150+
{
151+
if (screen->geometry().intersects(windowRect))
152+
{
153+
visibleOnAnyScreen = true;
154+
break;
155+
}
156+
}
157+
158+
if (visibleOnAnyScreen == false)
159+
pos = QPoint(40, 40);
160+
161+
move(pos);
138162
resize(size);
139163

140164
settings.endGroup();

0 commit comments

Comments
 (0)