LCOV - code coverage report
Current view: top level - vcl/source/helper - lazydelete.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 41 95.1 %
Date: 2014-11-03 Functions: 10 12 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "vcl/window.hxx"
      21             : #include "vcl/menu.hxx"
      22             : #include "vcl/lazydelete.hxx"
      23             : #include "svdata.hxx"
      24             : 
      25             : namespace vcl {
      26             : 
      27        5298 : LazyDeletorBase::LazyDeletorBase()
      28             : {
      29        5298 : }
      30             : 
      31        5198 : LazyDeletorBase::~LazyDeletorBase()
      32             : {
      33        5198 : }
      34             : 
      35             : // instantiate instance pointers for LazyDeletor<Window,Menu>
      36             : template<> LazyDeletor<vcl::Window>* LazyDeletor<vcl::Window>::s_pOneInstance = NULL;
      37             : template<> LazyDeletor<Menu>* LazyDeletor<Menu>::s_pOneInstance = NULL;
      38             : 
      39             : // a list for all LazyeDeletor<T> singletons
      40         411 : static std::vector< LazyDeletorBase* > lcl_aDeletors;
      41             : 
      42        5298 : void LazyDelete::addDeletor( LazyDeletorBase* i_pDel )
      43             : {
      44        5298 :     lcl_aDeletors.push_back( i_pDel );
      45        5298 : }
      46             : 
      47     1300914 : void LazyDelete::flush()
      48             : {
      49             :     DBG_TESTSOLARMUTEX(); // must be locked
      50             : 
      51     1300914 :     unsigned int nCount = lcl_aDeletors.size();
      52     1306112 :     for( unsigned int i = 0; i < nCount; i++ )
      53        5198 :         delete lcl_aDeletors[i];
      54     1300914 :     lcl_aDeletors.clear();
      55     1300914 : }
      56             : 
      57             : // specialized is_less function for Window
      58         156 : template<> bool LazyDeletor<vcl::Window>::is_less( vcl::Window* left, vcl::Window* right )
      59             : {
      60         156 :     return left != right && right->IsChild( left, true );
      61             : }
      62             : 
      63             : #ifndef LINUX
      64             : // specialized is_less function for Menu
      65             : template<> bool LazyDeletor<Menu>::is_less( Menu* left, Menu* right )
      66             : {
      67             :     while( left && left != right )
      68             :         left = left->ImplGetStartedFrom();
      69             :     return left != NULL;
      70             : }
      71             : #endif
      72             : 
      73         904 : DeleteOnDeinitBase::~DeleteOnDeinitBase()
      74             : {
      75         904 :     ImplSVData* pSVData = ImplGetSVData();
      76         904 :     if( pSVData && pSVData->mpDeinitDeleteList != NULL )
      77           4 :         pSVData->mpDeinitDeleteList->remove( this );
      78         904 : }
      79             : 
      80         904 : void DeleteOnDeinitBase::addDeinitContainer( DeleteOnDeinitBase* i_pContainer )
      81             : {
      82         904 :     ImplSVData* pSVData = ImplGetSVData();
      83         904 :     if( ! pSVData )
      84             :     {
      85           0 :         ImplInitSVData();
      86           0 :         pSVData = ImplGetSVData();
      87             :     }
      88             : 
      89             :     DBG_ASSERT( ! pSVData->mbDeInit, "DeleteOnDeinit added after DeiInitVCL !" );
      90         904 :     if( pSVData->mbDeInit )
      91         904 :         return;
      92             : 
      93         904 :     if( pSVData->mpDeinitDeleteList == NULL )
      94         112 :         pSVData->mpDeinitDeleteList = new std::list< DeleteOnDeinitBase* >();
      95         904 :     pSVData->mpDeinitDeleteList->push_back( i_pContainer );
      96             : }
      97             : 
      98         367 : void DeleteOnDeinitBase::ImplDeleteOnDeInit()
      99             : {
     100         367 :     ImplSVData* pSVData = ImplGetSVData();
     101         367 :     if( pSVData->mpDeinitDeleteList )
     102             :     {
     103        3030 :         for( std::list< vcl::DeleteOnDeinitBase* >::iterator it = pSVData->mpDeinitDeleteList->begin();
     104        2020 :              it != pSVData->mpDeinitDeleteList->end(); ++it )
     105             :         {
     106         900 :             (*it)->doCleanup();
     107             :         }
     108         110 :         delete pSVData->mpDeinitDeleteList;
     109         110 :         pSVData->mpDeinitDeleteList = NULL;
     110             :     }
     111         367 : }
     112             : 
     113        1233 : } // namespace vcl
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10