[Kstars-devel] KDE/kdeedu/kstars/kstars
Alexey Khudyakov
alexey.skladnoy at gmail.com
Wed Jun 3 19:42:29 CEST 2009
SVN commit 977251 by khudyakov:
* Oops. Restore copy constructor for StarObject. It set updateID
and updateNumID to 0. Compiler derived version does not. Fixed.
* In ConjunctionsTool::slotFindObject() use clone() instead of
kind of RTTI. It shorter and safer this way.
* Fix copy constructor of DeepSkyObject so it copy QImage right
and does not cause segfaults
CCMAIL: kstars-devel at kde.org
M +2 -2 skyobjects/deepskyobject.cpp
M +2 -4 skyobjects/deepskyobject.h
M +14 -0 skyobjects/starobject.cpp
M +5 -1 skyobjects/starobject.h
M +1 -20 tools/conjunctions.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/deepskyobject.cpp #977250:977251
@@ -38,9 +38,9 @@
UGC( o.UGC ),
PGC( o.PGC ),
MajorAxis( o.MajorAxis ),
- MinorAxis( o.MinorAxis ),
- Image(new QImage(*o.Image))
+ MinorAxis( o.MinorAxis )
{
+ Image = o.Image ? new QImage(*o.Image) : 0;
updateID = updateNumID = 0;
}
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/deepskyobject.h #977250:977251
@@ -94,10 +94,8 @@
virtual DeepSkyObject* clone() const;
- /**
- *Destructor
- */
- ~DeepSkyObject() { if ( Image ) { deleteImage(); } }
+ /** *Destructor */
+ virtual ~DeepSkyObject() { delete Image; }
/**
*@enum CATALOG
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/starobject.cpp #977250:977251
@@ -115,6 +115,20 @@
updateID = updateNumID = 0;
}
+StarObject::StarObject( const StarObject &o ) :
+ SkyObject (o),
+ PM_RA(o.PM_RA),
+ PM_Dec(o.PM_Dec),
+ Parallax(o.Parallax),
+ Multiplicity(o.Multiplicity),
+ Variability(o.Variability),
+ HD(o.HD)
+{
+ SpType[0] = o.SpType[0];
+ SpType[1] = o.SpType[1];
+ updateID = updateNumID = 0;
+}
+
StarObject* StarObject::clone() const
{
return new StarObject(*this);
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/starobject.h #977250:977251
@@ -41,7 +41,8 @@
*@version 1.0
*/
-class StarObject : public SkyObject {
+class StarObject : public SkyObject
+{
public:
/** @short returns the reindex interval (in centuries!) for the given
@@ -91,6 +92,9 @@
virtual StarObject* clone() const;
+ /** Copy constructor */
+ StarObject(const StarObject& o);
+
/**
* Destructor. (Empty)
*/
--- trunk/KDE/kdeedu/kstars/kstars/tools/conjunctions.cpp #977250:977251
@@ -132,26 +132,7 @@
delete Object1;
if( !fd->selectedObject() )
return;
- if( !fd->selectedObject()->isSolarSystem() ) {
- Object1 = new SkyObject( *fd->selectedObject() );
- }
- else {
- switch( fd->selectedObject()->type() ) {
- case 9: {
- Object1 = new KSComet( (KSComet &) *fd->selectedObject() );
- break;
- }
- case 10: {
- Object1 = new KSAsteroid( (KSAsteroid &) *fd->selectedObject() );
- break;
- }
- case 2:
- default: {
- Object1 = KSPlanetBase::createPlanet( pNames.key( fd->selectedObject()->name() ) ); // TODO: Fix i18n issues.
- break;
- }
- }
- }
+ Object1 = fd->selectedObject()->clone();
if( Object1 )
Obj1FindButton->setText( Object1->name() );
}
More information about the Kstars-devel
mailing list