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

Jason Harris kstars at 30doradus.org
Thu Dec 6 16:02:36 CET 2007


SVN commit 745603 by harris:

Fixing crash in jupiter moons tool.

This is a strange one.  Before applying this patch, opening the
jupiter moons tool (Ctrl+J) would crash KStars immediately (though I
clearly remember using it with no problem recently).  The backtrace
indicated the last code executed was ~JupiterMoons(), which consisted
of a single line:

    delete[] Moon;

because the four moons were stored as an array of TrailObject
pointers.  After a long time spent trying various fixes (I was misled
into thinking the problem was related to KPlotWidget, because there's
a similar-seeming and still-unresolved crash in modvizequinox, and
both use a KPlotWidget), I decided to change from an array of
TrailObject pointers to a QList.  Now the dtor looks like:

    qDeleteAll( Moon );

voila', no more crash.

I don't claim to understand what's going on here...

CCMAIL: kstars-devel at kde.org




 M  +5 -5      jupitermoons.cpp  
 M  +2 -1      jupitermoons.h  
 M  +4 -4      tools/jmoontool.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/jupitermoons.cpp #745602:745603
@@ -27,10 +27,10 @@
 JupiterMoons::JupiterMoons(){
     //Initialize the Moon objects.  The magnitude data are from the 
     //wikipedia articles for each moon, as of Oct 2007.
-    Moon[0] = new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.0, i18nc( "Jupiter's moon Io", "Io" ) );
-    Moon[1] = new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.3, i18nc( "Jupiter's moon Europa", "Europa" ) );
-    Moon[2] = new TrailObject( SkyObject::MOON, 0.0, 0.0, 4.6, i18nc( "Jupiter's moon Ganymede", "Ganymede" ) );
-    Moon[3] = new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.7, i18nc( "Jupiter's moon Callisto", "Callisto" ) );
+    Moon.append( new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.0, i18nc( "Jupiter's moon Io", "Io" ) ) );
+    Moon.append( new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.3, i18nc( "Jupiter's moon Europa", "Europa" ) ) );
+    Moon.append( new TrailObject( SkyObject::MOON, 0.0, 0.0, 4.6, i18nc( "Jupiter's moon Ganymede", "Ganymede" ) ) );
+    Moon.append( new TrailObject( SkyObject::MOON, 0.0, 0.0, 5.7, i18nc( "Jupiter's moon Callisto", "Callisto" ) ) );
 
     for ( uint i=0; i<4; ++i ) {
         XJ[i] = 0.0;
@@ -40,7 +40,7 @@
 }
 
 JupiterMoons::~JupiterMoons(){
-    delete[] Moon;
+    qDeleteAll( Moon );
 }
 
 QString JupiterMoons::name( int id ) const { 
--- trunk/KDE/kdeedu/kstars/kstars/jupitermoons.h #745602:745603
@@ -19,6 +19,7 @@
 #define JUPITERMOONS_H_
 
 #include <QString>
+#include <QList>
 
 class KSNumbers;
 class KSPlanet;
@@ -121,7 +122,7 @@
     double z( int i ) const { return ZJ[i]; }
 
 private:
-    TrailObject *Moon[4];
+    QList<TrailObject*> Moon;
     bool InFront[4];
     //the rectangular position, relative to Jupiter.  X-axis is equator of Jupiter; usints are Jup. Radius
     double XJ[4], YJ[4], ZJ[4];
--- trunk/KDE/kdeedu/kstars/kstars/tools/jmoontool.cpp #745602:745603
@@ -24,17 +24,17 @@
 
 #include <kdebug.h>
 #include <klocale.h>
+#include <KPlotWidget>
+#include <KPlotObject>
+#include <KPlotAxis>
 
-#include "jupitermoons.h"
 #include "kstars.h"
 #include "kstarsdata.h"
 #include "ksplanet.h"
 #include "simclock.h"
 #include "dms.h"
 #include "ksnumbers.h"
-#include "kplotwidget.h"
-#include "kplotobject.h"
-#include "kplotaxis.h"
+#include "jupitermoons.h"
 
 JMoonTool::JMoonTool(QWidget *parent)
         : KDialog( parent )


More information about the Kstars-devel mailing list