Skip to content

Commit f060afc

Browse files
fix(screenshot): prevent multiple simultaneous screenshot requests
- Updated the screenshot service to ignore new requests if a screenshot is already in progress, ensuring that only one instance of the screenshot process runs at a time. - Added debug logging to indicate when a screenshot is already in progress and when a new screenshot instance is started. This change improves the user experience by preventing overlapping screenshot operations. bug: https://pms.uniontech.com/bug-view-357037.html
1 parent aa699ce commit f060afc

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/dbusservice/dbusscreenshotservice.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,15 @@ void DBusScreenshotService::TopWindowScreenshot()
163163
{"startup_mode", "B3"}
164164
};
165165
EventLogUtils::get().writeLogs(obj);
166-
if (!m_singleInstance) {
167-
qCDebug(dsrApp) << "Starting new top window screenshot instance";
168-
parent()->topWindowScreenshot();
166+
if (m_singleInstance) {
167+
qCDebug(dsrApp) << "Screenshot already in progress, ignoring.";
168+
return;
169169
}
170+
// topWindowScreenshot() 内部会同步调用 saveAction() → QFileDialog,
171+
// 模态对话框的嵌套事件循环仍会处理 D-Bus 消息,必须在调用前置标志位
170172
m_singleInstance = true;
173+
qCDebug(dsrApp) << "Starting new top window screenshot instance";
174+
parent()->topWindowScreenshot();
171175
qCDebug(dsrApp) << "TopWindowScreenshot method finished.";
172176
}
173177

@@ -182,11 +186,15 @@ void DBusScreenshotService::FullscreenScreenshot()
182186
{"startup_mode", "B1"}
183187
};
184188
EventLogUtils::get().writeLogs(obj);
185-
if (!m_singleInstance) {
186-
qCDebug(dsrApp) << "Starting new fullscreen screenshot instance";
187-
parent()->fullscreenScreenshot();
189+
if (m_singleInstance) {
190+
qCDebug(dsrApp) << "Screenshot already in progress, ignoring.";
191+
return;
188192
}
193+
// fullscreenScreenshot() 内部会同步调用 saveAction() → QFileDialog,
194+
// 模态对话框的嵌套事件循环仍会处理 D-Bus 消息,必须在调用前置标志位
189195
m_singleInstance = true;
196+
qCDebug(dsrApp) << "Starting new fullscreen screenshot instance";
197+
parent()->fullscreenScreenshot();
190198
qCDebug(dsrApp) << "FullscreenScreenshot method finished.";
191199
}
192200

0 commit comments

Comments
 (0)