[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkstars=5D_kstars/tools=3A_refactor_new_code_a_bit_a?=
From:       Khudyakov Alexey <alexey.skladnoy () gmail ! com>
Date:       2011-05-01 21:40:14
Message-ID: 20110501214014.E2606A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit ba9af00af73e6c78353dc72447d4fe8bc6f94fc7 by Khudyakov Alexey.
Committed on 27/04/2011 at 14:32.
Pushed by khudyakov into branch 'master'.

refactor new code a bit and fix a mem leak.

KSNumbers *num were not freed

M  +9    -18   kstars/tools/altvstime.cpp     

http://commits.kde.org/kstars/ba9af00af73e6c78353dc72447d4fe8bc6f94fc7

diff --git a/kstars/tools/altvstime.cpp b/kstars/tools/altvstime.cpp
index 6f0d014..bedaab1 100644
--- a/kstars/tools/altvstime.cpp
+++ b/kstars/tools/altvstime.cpp
@@ -470,45 +470,36 @@ void AltVsTime::setDawnDusk()
 {
     KStarsData* data = KStarsData::Instance();
     KStarsDateTime today = getDate();
-    KSNumbers *oldNum = new KSNumbers( data->ut().djd() );
-    KSNumbers *num = new KSNumbers( today.djd() );
+    KSNumbers oldNum( data->ut().djd() );
+    KSNumbers num( today.djd() );
     dms LST = geo->GSTtoLST( today.gst() );
     
     SkyObject* o = KStarsData::Instance()->skyComposite()->findByName( "Sun" );
-    o->updateCoords( num, true, geo->lat(), &LST );
-    double alt, dawn, da, dusk, du, max_alt, min_alt;
+    o->updateCoords( &num, true, geo->lat(), &LST );
+    double dawn, da, dusk, du, max_alt, min_alt;
     double last_h = -12.0;
     double last_alt = findAltitude( o, last_h );
     dawn = dusk = -13.0;
     max_alt = -100.0;
     min_alt = 100.0;
-    bool asc;
     for ( double h=-11.95; h<=12.0; h+=0.05 ) {
-        alt = findAltitude( o, h );
-
-        if ( alt - last_alt > 0 )
-            asc = true;
-        else
-            asc = false;
-
+        double alt = findAltitude( o, h );
+        bool   asc = alt - last_alt > 0;
         if ( alt > max_alt )
             max_alt = alt;
-
         if ( alt < min_alt )
             min_alt = alt;
 
         if ( asc && last_alt <= -18.0 && alt >= -18.0 )
             dawn = h;
-
-        if ( ! asc && last_alt >= -18.0 && alt <= -18.0 )
+        if ( !asc && last_alt >= -18.0 && alt <= -18.0 )
             dusk = h;
 
-        last_h = h;
+        last_h   = h;
         last_alt = alt;
     }
 
-    o->updateCoords( oldNum, true, data->geo()->lat(), data->lst() );
-    delete oldNum;
+    o->updateCoords( &oldNum, true, data->geo()->lat(), data->lst() );
 
     if ( dawn < -12.0 || dusk < -12.0 ) {
         da = -1.0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic