[Kstars-devel] KDE/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Fri May 30 22:04:27 CEST 2008
SVN commit 814596 by asimha:
Fixing management of static data in KSMoon, by adding a static
variable that keeps track of the number of instances of KSMoon and
destroys the static data only when all instances are destroyed.
CCMAIL: kstars-devel at kde.org
M +8 -2 ksmoon.cpp
M +1 -0 ksmoon.h
--- trunk/KDE/kdeedu/kstars/kstars/ksmoon.cpp #814595:814596
@@ -32,16 +32,22 @@
KSMoon::KSMoon(KStarsData *kd)
: KSPlanetBase( kd, I18N_NOOP( "Moon" ), QString(), QColor("white"), 3474.8 /*diameter in km*/ )
{
+ instance_count++;
//Reset object type
setType( SkyObject::MOON );
}
KSMoon::~KSMoon() {
- while ( ! LRData.isEmpty() ) delete LRData.takeFirst();
- while ( ! BData.isEmpty() ) delete BData.takeFirst();
+ instance_count--;
+ if(instance_count <= 0) {
+ while ( ! LRData.isEmpty() ) delete LRData.takeFirst();
+ while ( ! BData.isEmpty() ) delete BData.takeFirst();
+ data_loaded = false;
+ }
}
bool KSMoon::data_loaded = false;
+int KSMoon::instance_count = 0;
QList<KSMoon::MoonLRData*> KSMoon::LRData;
QList<KSMoon::MoonBData*> KSMoon::BData;
--- trunk/KDE/kdeedu/kstars/kstars/ksmoon.h #814595:814596
@@ -85,6 +85,7 @@
private:
dms Phase;
static bool data_loaded;
+ static int instance_count;
/**@class MoonLRData
*Encapsulates the Longitude and radius terms of the sums
More information about the Kstars-devel
mailing list