1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <config_features.h> 21 22 #include <basic/sbstar.hxx> 23 #include <tools/debug.hxx> 24 25 #include <sfx2/app.hxx> 26 #include <appdata.hxx> 27 #include <sfx2/dispatch.hxx> 28 #include <sfx2/msgpool.hxx> 29 #include <sfx2/fcontnr.hxx> 30 #include <nochaos.hxx> 31 #include <sfx2/doctempl.hxx> 32 #include <sfx2/viewfrm.hxx> 33 #include <sfx2/objsh.hxx> 34 #include <appbaslib.hxx> 35 #include <childwinimpl.hxx> 36 #include <ctrlfactoryimpl.hxx> 37 #include <shellimpl.hxx> 38 #include <basic/basicmanagerrepository.hxx> 39 40 using ::basic::BasicManagerRepository; 41 Deinitialize()42void SfxApplication::Deinitialize() 43 { 44 if (pImpl->bDowning) 45 return; 46 47 #if HAVE_FEATURE_SCRIPTING 48 StarBASIC::Stop(); 49 50 SaveBasicAndDialogContainer(); 51 #endif 52 53 pImpl->bDowning = true; // due to Timer from DecAliveCount and QueryExit 54 55 pImpl->pTemplates.reset(); 56 57 // By definition there shouldn't be any open view frames when we reach 58 // this method. Therefore this call makes no sense and is the source of 59 // some stack traces, which we don't understand. 60 // For more information see: 61 pImpl->bDowning = false; 62 DBG_ASSERT(!SfxViewFrame::GetFirst(), "existing SfxViewFrame after Execute"); 63 DBG_ASSERT(!SfxObjectShell::GetFirst(), "existing SfxObjectShell after Execute"); 64 pImpl->pAppDispat->Pop(*this, SfxDispatcherPopFlags::POP_UNTIL); 65 pImpl->pAppDispat->Flush(); 66 pImpl->bDowning = true; 67 pImpl->pAppDispat->DoDeactivate_Impl(true, nullptr); 68 69 // Release Controller and others 70 // then the remaining components should also disappear ( Beamer! ) 71 72 #if HAVE_FEATURE_SCRIPTING 73 BasicManagerRepository::resetApplicationBasicManager(); 74 pImpl->pBasicManager->reset(nullptr); // this will also delete pBasMgr 75 #endif 76 77 DBG_ASSERT(pImpl->pViewFrame == nullptr, "active foreign ViewFrame"); 78 79 // free administration managers 80 pImpl->pAppDispat.reset(); 81 82 // from here no SvObjects have to exists 83 pImpl->pMatcher.reset(); 84 85 pImpl->pSlotPool.reset(); 86 pImpl->pFactArr.reset(); 87 88 pImpl->pTbxCtrlFac.reset(); 89 pImpl->pStbCtrlFac.reset(); 90 pImpl->pViewFrames.reset(); 91 pImpl->pViewShells.reset(); 92 pImpl->pObjShells.reset(); 93 94 //TODO/CLEANUP 95 //ReleaseArgs could be used instead! 96 pImpl->pPool = nullptr; 97 NoChaos::ReleaseItemPool(); 98 99 #if HAVE_FEATURE_SCRIPTING 100 pImpl->m_pSbxErrorHdl.reset(); 101 #endif 102 pImpl->m_pSoErrorHdl.reset(); 103 pImpl->m_pToolsErrorHdl.reset(); 104 } 105 106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 107