From kde-commits Fri May 30 20:04:27 2008 From: Akarsh Simha Date: Fri, 30 May 2008 20:04:27 +0000 To: kde-commits Subject: KDE/kdeedu/kstars/kstars Message-Id: <1212177867.955502.10504.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=121217787621281 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@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::LRData; QList 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