LCOV - code coverage report
Current view: top level - vcl/source/helper - lazydelete.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 39 41 95.1 %
Date: 2014-04-11 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        1923 : LazyDeletorBase::LazyDeletorBase()
      28             : {
      29        1923 : }
      30             : 
      31        1887 : LazyDeletorBase::~LazyDeletorBase()
      32             : {
      33        1887 : }
      34             : 
      35             : // instantiate instance pointers for LazyDeletor<Window,Menu>
      36             : template<> LazyDeletor<Window>* LazyDeletor<Window>::s_pOneInstance = NULL;
      37             : template<> LazyDeletor<Menu>* LazyDeletor<Menu>::s_pOneInstance = NULL;
      38             : 
      39             : // a list for all LazyeDeletor<T> singletons
      40         172 : static std::vector< LazyDeletorBase* > lcl_aDeletors;
      41             : 
      42        1923 : void LazyDelete::addDeletor( LazyDeletorBase* i_pDel )
      43             : {
      44        1923 :     lcl_aDeletors.push_back( i_pDel );
      45        1923 : }
      46             : 
      47      143688 : void LazyDelete::flush()
      48             : {
      49             :     DBG_TESTSOLARMUTEX(); // must be locked
      50             : 
      51      143688 :     unsigned int nCount = lcl_aDeletors.size();
      52      145575 :     for( unsigned int i = 0; i < nCount; i++ )
      53        1887 :         delete lcl_aDeletors[i];
      54      143688 :     lcl_aDeletors.clear();
      55      143688 : }
      56             : 
      57             : // specialized is_less function for Window
      58          60 : template<> bool LazyDeletor<Window>::is_less( Window* left, Window* right )
      59             : {
      60          60 :     return (left != right && right->IsChild( left, true )) ? true : false;
      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         366 : DeleteOnDeinitBase::~DeleteOnDeinitBase()
      74             : {
      75         366 :     ImplSVData* pSVData = ImplGetSVData();
      76         366 :     if( pSVData && pSVData->mpDeinitDeleteList != NULL )
      77         148 :         pSVData->mpDeinitDeleteList->remove( this );
      78         366 : }
      79             : 
      80         366 : void DeleteOnDeinitBase::addDeinitContainer( DeleteOnDeinitBase* i_pContainer )
      81             : {
      82         366 :     ImplSVData* pSVData = ImplGetSVData();
      83         366 :     if( ! pSVData )
      84             :     {
      85           0 :         ImplInitSVData();
      86           0 :         pSVData = ImplGetSVData();
      87             :     }
      88             : 
      89             :     DBG_ASSERT( ! pSVData->mbDeInit, "DeleteOnDeinit added after DeiInitVCL !" );
      90         366 :     if( pSVData->mbDeInit )
      91         366 :         return;
      92             : 
      93         366 :     if( pSVData->mpDeinitDeleteList == NULL )
      94          49 :         pSVData->mpDeinitDeleteList = new std::list< DeleteOnDeinitBase* >();
      95         366 :     pSVData->mpDeinitDeleteList->push_back( i_pContainer );
      96             : }
      97             : 
      98          91 : void DeleteOnDeinitBase::ImplDeleteOnDeInit()
      99             : {
     100          91 :     ImplSVData* pSVData = ImplGetSVData();
     101          91 :     if( pSVData->mpDeinitDeleteList )
     102             :     {
     103         747 :         for( std::list< vcl::DeleteOnDeinitBase* >::iterator it = pSVData->mpDeinitDeleteList->begin();
     104         498 :              it != pSVData->mpDeinitDeleteList->end(); ++it )
     105             :         {
     106         218 :             (*it)->doCleanup();
     107             :         }
     108          31 :         delete pSVData->mpDeinitDeleteList;
     109          31 :         pSVData->mpDeinitDeleteList = NULL;
     110             :     }
     111          91 : }
     112             : 
     113         516 : } // namespace vcl
     114             : 
     115             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10