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

Jason Harris kstars at 30doradus.org
Sat Oct 27 17:36:52 CEST 2007


SVN commit 729977 by harris:

Jure: thanks for finding a memory leak in KStars!  Unfortunately, your fix
was not correct, because we set "pLast = pThis" prior to your "delete
pThis".  Therefore, pLast would be a null pointer when we still need
it.

Instead, I have made pThis and pLast normal objects, rather than
pointers.  James, can you review this patch?  I am in the midst of a
large set of changes ATM, so my local copy is not compilable.

CCMAIL: jlp at holodeck1.com
CCMAIL: kstars-devel at kde.org



 M  +9 -10     skymapdraw.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/skymapdraw.cpp #729976:729977
@@ -227,41 +227,40 @@
     if (bound->size() < 2) return;
 
     bool isVisible, isVisibleLast;
-    SkyPoint  *pThis, *pLast;
+    SkyPoint pThis, pLast;
     QPointF oThis, oLast, oMid;
 
     QPointF node = bound->at( 0 );
-    pLast = new SkyPoint( node.x(), node.y() );
+    pLast.set( node.x(), node.y() );
 
-    pLast->EquatorialToHorizontal( data->LST, data->geo()->lat() );
-    oLast = toScreen( pLast, Options::useRefraction(), &isVisibleLast );
+    pLast.EquatorialToHorizontal( data->LST, data->geo()->lat() );
+    oLast = toScreen( &pLast, Options::useRefraction(), &isVisibleLast );
 
     int limit = bound->size();
 
     for ( int i=1 ; i < limit ; i++ ) {
         node = bound->at( i );
-        pThis = new SkyPoint( node.x(), node.y() );
-        pThis->EquatorialToHorizontal( data->LST, data->geo()->lat() );
-        oThis = toScreen( pThis, Options::useRefraction(), &isVisible );
+        pThis.set( node.x(), node.y() );
+        pThis.EquatorialToHorizontal( data->LST, data->geo()->lat() );
+        oThis = toScreen( &pThis, Options::useRefraction(), &isVisible );
 
         if ( isVisible && isVisibleLast ) {
             psky.drawLine( oLast, oThis );
         }
 
         else if ( isVisibleLast ) {
-            oMid = clipLineI( pLast, pThis );
+            oMid = clipLineI( &pLast, &pThis );
             // -jbb printf("oMid: %4d %4d\n", oMid.x(), oMid.y());
             psky.drawLine( oLast, oMid );
         }
         else if ( isVisible ) {
-            oMid = clipLineI( pThis, pLast );
+            oMid = clipLineI( &pThis, &pLast );
             psky.drawLine( oMid, oThis );
         }
 
         pLast = pThis;
         oLast = oThis;
         isVisibleLast = isVisible;
-        delete pThis;
     }
     /****
     	QPolygonF poly;


More information about the Kstars-devel mailing list