• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • sources
  • kde-4.14
  • kdelibs
  • kde3support
  • kdecore
k3staticdeleter.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the KDE Libraries
3  * Copyright (C) 2000 Stephan Kulow <coolo@kde.org>
4  * 2001 KDE Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "k3staticdeleter.h"
24 #include <kglobal.h>
25 
26 #include <QtCore/QList>
27 #include <QtCore/QCoreApplication>
28 
29 typedef QList<K3StaticDeleterBase *> K3StaticDeleterList;
30 
31 struct K3StaticDeleterPrivate
32 {
33  K3StaticDeleterPrivate()
34  {
35  qAddPostRoutine(deleteStaticDeleters);
36  }
37  ~K3StaticDeleterPrivate()
38  {
39  qRemovePostRoutine(deleteStaticDeleters);
40  deleteStaticDeleters();
41  }
42  static void deleteStaticDeleters();
43 
44  K3StaticDeleterList staticDeleters;
45 };
46 
47 K_GLOBAL_STATIC(K3StaticDeleterPrivate, staticDeleterPrivate)
48 
49 void K3StaticDeleterPrivate::deleteStaticDeleters()
50 {
51  if (staticDeleterPrivate.isDestroyed()) {
52  return;
53  }
54  K3StaticDeleterPrivate *d = staticDeleterPrivate;
55  while (!d->staticDeleters.isEmpty()) {
56  d->staticDeleters.takeLast()->destructObject();
57  }
58 }
59 
60 void K3StaticDeleterHelpers::registerStaticDeleter(K3StaticDeleterBase *obj)
61 {
62  K3StaticDeleterPrivate *d = staticDeleterPrivate;
63  if (d->staticDeleters.indexOf(obj) == -1) {
64  d->staticDeleters.append(obj);
65  }
66 }
67 
68 void K3StaticDeleterHelpers::unregisterStaticDeleter(K3StaticDeleterBase *obj)
69 {
70  if (staticDeleterPrivate.isDestroyed()) {
71  return;
72  }
73  staticDeleterPrivate->staticDeleters.removeAll(obj);
74 }
75 
76 void K3StaticDeleterHelpers::deleteStaticDeleters()
77 {
78  staticDeleterPrivate->deleteStaticDeleters();
79 }
80 
81 // this helps gcc to emit the vtbl for K3StaticDeleterBase
82 // only once, here in this file, not every time it's
83 // used, says Seli and thiago.
84 K3StaticDeleterBase::~K3StaticDeleterBase()
85 {
86 }
87 
88 void K3StaticDeleterBase::destructObject()
89 {
90 }
91 
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
K3StaticDeleterList
QList< K3StaticDeleterBase * > K3StaticDeleterList
Definition: k3staticdeleter.cpp:29
K3StaticDeleterHelpers::registerStaticDeleter
void registerStaticDeleter(K3StaticDeleterBase *d)
Registers a static deleter.
Definition: k3staticdeleter.cpp:60
kglobal.h
K3StaticDeleterHelpers::deleteStaticDeleters
void deleteStaticDeleters()
Calls K3StaticDeleterBase::destructObject() on all registered static deleters and unregisters them al...
Definition: k3staticdeleter.cpp:76
QList< K3StaticDeleterBase * >
K3StaticDeleterBase::~K3StaticDeleterBase
virtual ~K3StaticDeleterBase()
Definition: k3staticdeleter.cpp:84
K3StaticDeleterBase::destructObject
virtual void destructObject()
Should destruct the resources managed by this K3StaticDeleterBase.
Definition: k3staticdeleter.cpp:88
K3StaticDeleterHelpers::unregisterStaticDeleter
void unregisterStaticDeleter(K3StaticDeleterBase *d)
Unregisters a static deleter.
Definition: k3staticdeleter.cpp:68
k3staticdeleter.h
K3StaticDeleterBase
Base class for K3StaticDeleter.
Definition: k3staticdeleter.h:68
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal