[Kstars-devel] [kstars] kstars: Changing the definition of StarObject::JITUpdate() from JITUpdate(

Akarsh Simha akarshsimha at gmail.com
Sun Oct 30 09:03:44 UTC 2011


Git commit 92e6284a404ae1643b94f316fddfa527ead11d78 by Akarsh Simha.
Committed on 30/10/2011 at 09:40.
Pushed by asimha into branch 'master'.

Changing the definition of StarObject::JITUpdate() from JITUpdate(
KStarsData * ) to JITUpdate( void )

This is more efficient since there's one less argument to keep passing
around.

Instead JITUpdate gets its access to data from KStarsData::Instance().

I've made data within JITUpdate static. This could be a problem if
KStarsData is ever destroyed or recreated before the program
terminates! But that should not happen anyway, because it's going to
set a whole bunch of other things haywire as well.

Otherwise, this should introduce no bugs.

CCMAIL: kstars-devel at kde.org

M  +1    -1    kstars/skycomponents/constellationlines.cpp
M  +1    -1    kstars/skycomponents/deepstarcomponent.cpp
M  +3    -3    kstars/skycomponents/starcomponent.cpp
M  +3    -1    kstars/skyobjects/starobject.cpp
M  +1    -1    kstars/skyobjects/starobject.h

http://commits.kde.org/kstars/92e6284a404ae1643b94f316fddfa527ead11d78

diff --git a/kstars/skycomponents/constellationlines.cpp b/kstars/skycomponents/constellationlines.cpp
index 618ef24..a40e9bf 100644
--- a/kstars/skycomponents/constellationlines.cpp
+++ b/kstars/skycomponents/constellationlines.cpp
@@ -145,7 +145,7 @@ void ConstellationLines::JITupdate( LineList* lineList )
     SkyList* points = lineList->points();
     for (int i = 0; i < points->size(); i++ ) {
         StarObject* star = (StarObject*) points->at( i );
-        star->JITupdate( data );
+        star->JITupdate();
     }
 }
 
diff --git a/kstars/skycomponents/deepstarcomponent.cpp b/kstars/skycomponents/deepstarcomponent.cpp
index 0e412e7..7cf792a 100644
--- a/kstars/skycomponents/deepstarcomponent.cpp
+++ b/kstars/skycomponents/deepstarcomponent.cpp
@@ -281,7 +281,7 @@ void DeepStarComponent::draw( SkyPainter *skyp ) {
                 //<< ", and indexStar says he's from " << m_skyMesh->indexStar( curStar );
 
                 if ( curStar->updateID != updateID )
-                    curStar->JITupdate( data );
+                    curStar->JITupdate();
 
                 float mag = curStar->mag();
 
diff --git a/kstars/skycomponents/starcomponent.cpp b/kstars/skycomponents/starcomponent.cpp
index 3c402a3..feb3e05 100644
--- a/kstars/skycomponents/starcomponent.cpp
+++ b/kstars/skycomponents/starcomponent.cpp
@@ -302,7 +302,7 @@ void StarComponent::draw( SkyPainter *skyp )
                 break;
                  
             if ( curStar->updateID != updateID )
-                curStar->JITupdate( data );
+                curStar->JITupdate();
 
             bool drawn = skyp->drawPointSource( curStar, mag, curStar->spchar() );
 
@@ -315,7 +315,7 @@ void StarComponent::draw( SkyPainter *skyp )
     // Draw focusStar if not null
     if( focusStar ) {
         if ( focusStar->updateID != updateID )
-            focusStar->JITupdate( data );
+            focusStar->JITupdate();
         float mag = focusStar->mag();
         skyp->drawPointSource(focusStar, mag, focusStar->spchar() );
     }
@@ -552,7 +552,7 @@ SkyObject *StarComponent::findByHDIndex( int HDnum ) {
         }
         m_starObject.init( &stardata );
         m_starObject.EquatorialToHorizontal( data->lst(), data->geo()->lat() );
-        m_starObject.JITupdate( data );
+        m_starObject.JITupdate();
         focusStar = &m_starObject;
         hdidxReader.closeFile();
         return focusStar;
diff --git a/kstars/skyobjects/starobject.cpp b/kstars/skyobjects/starobject.cpp
index d83678e..a35ccd6 100644
--- a/kstars/skyobjects/starobject.cpp
+++ b/kstars/skyobjects/starobject.cpp
@@ -309,8 +309,10 @@ void StarObject::getIndexCoords( KSNumbers *num, double *ra, double *dec )
     //    *dec = dec0().Degrees() + ddec;
 }
 
-void StarObject::JITupdate( KStarsData* data )
+void StarObject::JITupdate()
 {
+    static KStarsData *data = KStarsData::Instance();
+
     updateID = data->updateID();
     if ( updateNumID != data->updateNumID() ) {
         // TODO: This can be optimized and reorganized further in a better manner.
diff --git a/kstars/skyobjects/starobject.h b/kstars/skyobjects/starobject.h
index 59c59cf..d375135 100644
--- a/kstars/skyobjects/starobject.h
+++ b/kstars/skyobjects/starobject.h
@@ -174,7 +174,7 @@ public:
     void getIndexCoords( KSNumbers *num, double *ra, double *dec );
 
     /**@short added for JIT updates from both StarComponent and ConstellationLines */
-    void JITupdate( KStarsData* data );
+    void JITupdate();
 
     /**@short returns the magnitude of the proper motion correction in milliarcsec/year */
     inline double pmMagnitude()



More information about the Kstars-devel mailing list