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

Jason Harris kstars at 30doradus.org
Sat Dec 15 00:32:59 CET 2007


SVN commit 748608 by harris:

Fix crash due to poor design in SkyLine, exposed by Angular Ruler tool.

CCMAIL: kstars-devel at kde.org


 M  +8 -1      skyline.cpp  
 M  +2 -0      skyline.h  
 M  +15 -20    skymap.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/skyline.cpp #748607:748608
@@ -44,7 +44,14 @@
 }
 
 SkyLine::~SkyLine() {
+  clear();
+}
+
+void SkyLine::clear() {
+  if ( m_pList.size() ) {
     qDeleteAll( m_pList );
+    m_pList.clear();
+  }
 }
 
 void SkyLine::append( const SkyPoint &p ) {
@@ -63,7 +70,7 @@
         return;
     }
 
-    m_pList[i]->set( p->ra(), p->dec() );
+    m_pList[i]->set( p->ra()->Hours(), p->dec()->Degrees() );
 }
 
 dms SkyLine::angularSize( int i ) const{
--- trunk/KDE/kdeedu/kstars/kstars/skyline.h #748607:748608
@@ -87,6 +87,8 @@
 
     inline QList<SkyPoint*>& points() { return m_pList; }
 
+    void clear();
+
     /**
     	*Set point i in the SkyLine
     	*@param i the index position of the point to modify
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #748607:748608
@@ -428,12 +428,19 @@
 }
 
 void SkyMap::slotBeginAngularDistance() {
-    //ANGULAR
-    //	setPreviousClickedPoint( mousePoint() );
     angularDistanceMode = true;
-    AngularRuler = SkyLine( mousePoint(), mousePoint() );
-    //	beginRulerPoint = toScreen( previousClickedPoint() );
-    //	endRulerPoint =  QPointF( beginRulerPoint.x(),beginRulerPoint.y() );
+    AngularRuler.clear();
+
+    //If the cursor is near a SkyObject, reset the AngularRuler's 
+    //start point to the position of the SkyObject
+    double maxrad = 1000.0/Options::zoomFactor();
+    if ( SkyObject *so = data->skyComposite()->objectNearest( mousePoint(), maxrad ) ) {
+        AngularRuler.append( so );
+        AngularRuler.append( so );
+    } else {
+        AngularRuler.append( mousePoint() );
+        AngularRuler.append( mousePoint() );
+    }
 }
 
 void SkyMap::slotEndAngularDistance() {
@@ -456,13 +463,13 @@
         ks->statusBar()->changeItem( sbMessage, 0 );
 
         angularDistanceMode=false;
-        AngularRuler = SkyLine(); //null SkyLine
+	AngularRuler.clear();
     }
 }
 
 void SkyMap::slotCancelAngularDistance(void) {
     angularDistanceMode=false;
-    AngularRuler = SkyLine(); //null SkyLine
+    AngularRuler.clear();
 }
 
 void SkyMap::slotImage() {
@@ -1614,19 +1621,7 @@
 }
 
 void SkyMap::updateAngleRuler() {
-    //determine RA, Dec of mouse pointer
-    QPoint mp( mapFromGlobal( QCursor::pos() ) );
-    double dx = ( 0.5*width()  - mp.x() )/Options::zoomFactor();
-    double dy = ( 0.5*height() - mp.y() )/Options::zoomFactor();
-
-    if (! unusablePoint (dx, dy)) {
-        SkyPoint p = fromScreen( dx, dy, data->LST, data->geo()->lat() );
-        AngularRuler.setPoint( 1, &p );
-    }
-
-    //DEBUG
-    kDebug() << "AngRuler: " << AngularRuler.point(0)->ra()->toHMSString() << " :: " << AngularRuler.point(1)->ra()->toHMSString();
-
+      AngularRuler.setPoint( 1, mousePoint() );
 }
 
 bool SkyMap::isSlewing() const  {


More information about the Kstars-devel mailing list