From e61888fc928404ae0f5b056a603d4e7564c58b80 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 6 Apr 2022 00:09:45 -0300 Subject: [PATCH] Fix compilation when ENABLE_UI is disabled and UIContext isn't defined --- src/app/app.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index f7d974a38..a78141cf3 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -380,16 +380,15 @@ namespace { #endif struct CloseAllDocs { - CloseAllDocs() { } + Context* m_ctx; + CloseAllDocs(Context* ctx) : m_ctx(ctx) { } ~CloseAllDocs() { - auto ctx = UIContext::instance(); - std::vector docs; #ifdef ENABLE_UI - for (Doc* doc : ctx->getAndRemoveAllClosedDocs()) + for (Doc* doc : static_cast(m_ctx)->getAndRemoveAllClosedDocs()) docs.push_back(doc); #endif - for (Doc* doc : ctx->documents()) + for (Doc* doc : m_ctx->documents()) docs.push_back(doc); for (Doc* doc : docs) { // First we close the document. In this way we receive recent @@ -416,7 +415,7 @@ void App::run() #ifdef ENABLE_UI CloseMainWindow closeMainWindow(m_mainWindow); #endif - CloseAllDocs closeAllDocsAtExit; + CloseAllDocs closeAllDocsAtExit(context()); #ifdef ENABLE_UI // Run the GUI