Skip to content

Commit 717fe1b

Browse files
add-uoslzwind
authored andcommitted
fix(editor): fix window close logic and lambda capture
Fix window close timing by checking tabbar count instead of just wrappers. Use proper lambda capture [this] to avoid StartManager::instance() race condition. 修复窗口关闭时机判断,添加标签页计数检查。 修复lambda捕获问题,使用this指针避免instance()竞态条件。 Log: 修复窗口关闭逻辑 PMS: BUG-365421 Influence: 修复编辑器关闭时可能出现的窗口未正确关闭问题,提升应用稳定性。
1 parent 7da46b7 commit 717fe1b

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/startmanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,8 @@ void StartManager::slotCloseWindow()
805805
// 导致被附加到上一文本编辑器进程
806806
QDBusConnection::sessionBus().unregisterService("com.deepin.Editor");
807807

808-
QTimer::singleShot(1000, []() {
809-
StartManager::instance()->delayMallocTrim();
808+
QTimer::singleShot(1000, [this]() {
809+
this->delayMallocTrim();
810810
QApplication::quit();
811811
});
812812

src/widgets/window.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,10 @@ void Window::removeWrapper(const QString &filePath, bool isDelete)
11991199
}
12001200
}
12011201

1202-
// Exit window after close all tabs.
1203-
if (m_wrappers.isEmpty()) {
1202+
// Exit window after close all tabs (including pending and blank tabs).
1203+
// Pending tabs are kept in m_pendingTabs, blank tabs are managed by the tabbar.
1204+
// Only close the window when the tabbar has no tabs left.
1205+
if (m_wrappers.isEmpty() && m_tabbar->count() == 0) {
12041206
close();
12051207
qInfo() << "after close";
12061208
}

0 commit comments

Comments
 (0)