LCOV - code coverage report
Current view: top level - vcl/source/helper - lazydelete.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 38 38 100.0 %
Date: 2015-06-13 12:38:46 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        3110 : LazyDeletorBase::LazyDeletorBase()
      28             : {
      29        3110 : }
      30             : 
      31        3049 : LazyDeletorBase::~LazyDeletorBase()
      32             : {
      33        3049 : }
      34             : 
      35             : // instantiate instance pointer for LazyDeletor<Window>
      36             : LazyDeletor* LazyDeletor::s_pOneInstance = NULL;
      37             : 
      38             : // a list for all LazyeDeletor<T> singletons
      39         267 : static std::vector< LazyDeletorBase* > lcl_aDeletors;
      40             : 
      41        3110 : void LazyDelete::addDeletor( LazyDeletorBase* i_pDel )
      42             : {
      43        3110 :     lcl_aDeletors.push_back( i_pDel );
      44        3110 : }
      45             : 
      46    13481491 : void LazyDelete::flush()
      47             : {
      48             :     DBG_TESTSOLARMUTEX(); // must be locked
      49             : 
      50    13481491 :     unsigned int nCount = lcl_aDeletors.size();
      51    13484540 :     for( unsigned int i = 0; i < nCount; i++ )
      52        3049 :         delete lcl_aDeletors[i];
      53    13481491 :     lcl_aDeletors.clear();
      54    13481491 : }
      55             : 
      56             : // specialized is_less function for Window
      57       12083 : bool LazyDeletor::is_less( vcl::Window* left, vcl::Window* right )
      58             : {
      59       12083 :     return left != right && right->IsChild( left, true );
      60             : }
      61             : 
      62         626 : DeleteOnDeinitBase::~DeleteOnDeinitBase()
      63             : {
      64         626 :     ImplSVData* pSVData = ImplGetSVData();
      65         626 :     if( pSVData && pSVData->mpDeinitDeleteList != NULL )
      66           2 :         pSVData->mpDeinitDeleteList->remove( this );
      67         626 : }
      68             : 
      69         626 : void DeleteOnDeinitBase::addDeinitContainer( DeleteOnDeinitBase* i_pContainer )
      70             : {
      71         626 :     ImplSVData* pSVData = ImplGetSVData();
      72             : 
      73             :     DBG_ASSERT( ! pSVData->mbDeInit, "DeleteOnDeinit added after DeiInitVCL !" );
      74         626 :     if( pSVData->mbDeInit )
      75         626 :         return;
      76             : 
      77         626 :     if( pSVData->mpDeinitDeleteList == NULL )
      78          78 :         pSVData->mpDeinitDeleteList = new std::list< DeleteOnDeinitBase* >();
      79         626 :     pSVData->mpDeinitDeleteList->push_back( i_pContainer );
      80             : }
      81             : 
      82         242 : void DeleteOnDeinitBase::ImplDeleteOnDeInit()
      83             : {
      84         242 :     ImplSVData* pSVData = ImplGetSVData();
      85         242 :     if( pSVData->mpDeinitDeleteList )
      86             :     {
      87        2103 :         for( std::list< vcl::DeleteOnDeinitBase* >::iterator it = pSVData->mpDeinitDeleteList->begin();
      88        1402 :              it != pSVData->mpDeinitDeleteList->end(); ++it )
      89             :         {
      90         624 :             (*it)->doCleanup();
      91             :         }
      92          77 :         delete pSVData->mpDeinitDeleteList;
      93          77 :         pSVData->mpDeinitDeleteList = NULL;
      94             :     }
      95         242 : }
      96             : 
      97         801 : } // namespace vcl
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11