From ee1d1c51dc99068645559184fb7fbde516c5f174 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Tue, 20 Feb 2024 14:41:10 +0800 Subject: [PATCH] Properly count the open tabs across multiple windows --- ui/uinotification.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/uinotification.cpp b/ui/uinotification.cpp index e3e156e..3e90542 100644 --- a/ui/uinotification.cpp +++ b/ui/uinotification.cpp @@ -81,13 +81,17 @@ void NotificationListener::OnAfterSaveFile(UIContext* context, FileContext* file bool NotificationListener::OnBeforeCloseFile(UIContext* context, FileContext* file, ViewFrame* frame) { auto mainWindow = context->mainWindow(); - auto tabs = context->getTabs(); + size_t count = 0; - for (auto tab : tabs) + for (const auto& ctx: UIContext::allContexts()) { - auto viewFrame = context->getViewFrameForTab(tab); - if (viewFrame && (viewFrame->getFileContext() == file)) - count++; + auto tabs = ctx->getTabs(); + for (auto tab : tabs) + { + auto viewFrame = ctx->getViewFrameForTab(tab); + if (viewFrame && (viewFrame->getFileContext() == file)) + count++; + } } // If this is not the last tab of the file being closed, return