[Kstars-devel] KDE/kdeedu/kstars/kstars

Alexey Khudyakov alexey.skladnoy at gmail.com
Thu Aug 6 17:41:24 CEST 2009


SVN commit 1007945 by khudyakov:

Make geoList anf RuleBook data member non-static for consistency.
KStarsData is a singleton.

Remove objects counter

CCMAIL: kstars-devel at kde.org


 M  +16 -44    kstarsdata.cpp  
 M  +2 -6      kstarsdata.h  


--- trunk/KDE/kdeedu/kstars/kstars/kstarsdata.cpp #1007944:1007945
@@ -51,18 +51,13 @@
 
 #include "dialogs/detaildialog.h"
 
-//Initialize static members
-QList<GeoLocation*> KStarsData::geoList = QList<GeoLocation*>();
 
-QMap<QString, TimeZoneRule> KStarsData::Rulebook = QMap<QString, TimeZoneRule>();
-
-int KStarsData::objects = 0;
-
 KStarsData* KStarsData::pinstance = 0;
 
 KStarsData* KStarsData::Create( KStars* kstars )
 {
-    if ( pinstance ) delete pinstance;
+    if ( pinstance )
+        delete pinstance;
     pinstance = new KStarsData( kstars );
     return pinstance;
 }
@@ -81,7 +76,6 @@
     m_preUpdateNum( J2000 ), m_updateNum( J2000 )
 {
     startupComplete = false;
-    objects++;
 
     TypeName[0] = i18n( "star" );
     TypeName[1] = i18n( "star" );
@@ -121,33 +115,20 @@
 }
 
 KStarsData::~KStarsData() {
-    //FIXME: Do we still need this?
-    objects--; //the number of existing KStarsData objects
-
-    //FIXME: Verify list of deletes
     delete locale;
     delete LST;
     delete HourAngle;
 
-    while ( ! geoList.isEmpty() )
-        delete geoList.takeFirst();
-
-    while ( !VariableStarsList.isEmpty())
-        delete VariableStarsList.takeFirst();
-
-    while ( !INDIHostsList.isEmpty())
-        delete INDIHostsList.takeFirst();
-
-    while ( !ADVtreeList.isEmpty())
-        delete ADVtreeList.takeFirst();
-
+    qDeleteAll( geoList );
+    qDeleteAll( VariableStarsList );
+    qDeleteAll( INDIHostsList );
+    qDeleteAll( ADVtreeList );
 }
 
 QString KStarsData::typeName( int i ) {
-    QString result = i18n( "no type" );
-    if ( i >= 0 && i < 12 ) result = TypeName[i];
-
-    return result;
+    if ( i >= 0 && i < 12 )
+        return TypeName[i];
+    return i18n( "no type" );
 }
 
 void KStarsData::initialize() {
@@ -201,27 +182,18 @@
     case 0: //Load Time Zone Rules//
         emit progressText( i18n("Reading time zone rules") );
 
-        if (objects==1) {
-            // timezone rules
-            if ( !readTimeZoneRulebook( ) )
-                initError( "TZrules.dat", true );
-        }
+        // timezone rules
+        if ( !readTimeZoneRulebook( ) )
+            initError( "TZrules.dat", true );
 
-
         break;
 
     case 1: //Load Cities//
-        {
-            if (objects>1) break;
+        emit progressText( i18n("Loading city data") );
+        if ( !readCityData( ) )
+            initError( "Cities.dat", true );
+        break;
 
-            emit progressText( i18n("Loading city data") );
-
-            if ( !readCityData( ) )
-                initError( "Cities.dat", true );
-
-            break;
-        }
-
     case 2: //Initialize SkyMapComposite//
 
         emit progressText(i18n("Loading sky objects" ) );
--- trunk/KDE/kdeedu/kstars/kstars/kstarsdata.h #1007944:1007945
@@ -449,8 +449,6 @@
 
     QList<SkyObject> objList;
 
-    // 	QPtrList<StarObject> starList;
-
     unsigned int StarCount;
 
     QList<VariableStarInfo*> VariableStarsList;
@@ -467,7 +465,6 @@
 
     bool TimeRunsForward, temporaryTrail, snapToFocus;
 
-    //	QString cnameFile;
     KLocale *locale;
 
     dms *LST, *HourAngle;
@@ -488,9 +485,8 @@
 
     //--- Static member variables
     //the number of KStarsData objects.
-    static int objects;
-    static QList<GeoLocation*> geoList;
-    static QMap<QString, TimeZoneRule> Rulebook;
+    QList<GeoLocation*> geoList;
+    QMap<QString, TimeZoneRule> Rulebook;
 
     KStars*      m_kstars;
     quint32      m_preUpdateID, m_updateID;


More information about the Kstars-devel mailing list