[Kstars-devel] KDE/kdeedu/kstars/kstars
Jason Harris
kstars at 30doradus.org
Tue Jan 29 15:54:09 CET 2008
SVN commit 768145 by harris:
Initialize the custom catalog when adding it. Otherwise there will
be a crash. Backporting to 4.0.
CCMAIL: kstars-devel at kde.org
M +12 -5 opscatalog.cpp
M +9 -4 skycomponents/skymapcomposite.cpp
M +1 -1 skycomponents/skymapcomposite.h
--- trunk/KDE/kdeedu/kstars/kstars/opscatalog.cpp #768144:768145
@@ -99,10 +99,19 @@
Options::setShowMessierImages( showMessImages->checkState() );
Options::setShowNGC( showNGC->checkState() );
Options::setShowIC( showIC->checkState() );
+
+ //DEBUG
+ kDebug() << ksw->data()->skyComposite()->customCatalogs().size() << endl;
+ kDebug() << ((CustomCatalogComponent*)ksw->data()->skyComposite()->customCatalogs()[0])->name() << endl;
+
for ( int i=0; i < ksw->data()->skyComposite()->customCatalogs().size(); ++i ) {
QString name = ((CustomCatalogComponent*)ksw->data()->skyComposite()->customCatalogs()[i])->name();
QList<QListWidgetItem*> l = CatalogList->findItems( name, Qt::MatchExactly );
- Options::showCatalog()[i] = (l[0]->checkState()==Qt::Checked) ? true : false;
+
+ //DEBUG
+ kDebug() << name << " : " << l.size() << endl;
+
+ Options::showCatalog()[i] = (l[0]->checkState()==Qt::Checked) ? 1 : 0;
}
// update time for all objects because they might be not initialized
@@ -135,7 +144,7 @@
QString filename = KFileDialog::getOpenFileName( QDir::homePath(), "*");
if ( ! filename.isEmpty() ) {
//test integrity of file before trying to add it
- CustomCatalogComponent newCat( 0, filename, true, Options::showOther );
+ CustomCatalogComponent newCat( ksw->data()->skyComposite(), filename, true, Options::showOther );
newCat.init( ksw->data() );
if ( newCat.objectList().size() )
insertCatalog( filename );
@@ -158,10 +167,8 @@
Options::setCatalogFile( tFileList );
Options::setShowCatalog( tShowList );
- //FIXME: Can't use Options::showCatalog[tShowList.size()-1] as visibility fcn,
- //because it returns QList rather than bool
//Add new custom catalog, based on the list of SkyObjects we just parsed
- ksw->data()->skyComposite()->addCustomCatalog( filename, Options::showOther );
+ ksw->data()->skyComposite()->addCustomCatalog( filename, ksw->data(), Options::showOther );
ksw->map()->forceUpdate();
}
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.cpp #768144:768145
@@ -100,8 +100,11 @@
//FIXME: can't use Options::showCatalog as visibility fcn,
//because it returns QList, not bool
m_CustomCatalogs = new SkyComposite( this );
- foreach ( const QString &fname, Options::catalogFile() )
- m_CustomCatalogs->addComponent( new CustomCatalogComponent( this, fname, false, &Options::showOther ) );
+ foreach ( const QString &fname, Options::catalogFile() ) {
+ CustomCatalogComponent *cc = new CustomCatalogComponent( this, fname, false, &Options::showOther );
+ cc->init( data );
+ m_CustomCatalogs->addComponent( cc );
+ }
m_SolarSystem = new SolarSystemComposite( this, data );
addComponent( m_SolarSystem );
@@ -409,8 +412,10 @@
}
**/
-void SkyMapComposite::addCustomCatalog( const QString &filename, bool (*visibleMethod)() ) {
- m_CustomCatalogs->addComponent( new CustomCatalogComponent( this, filename, false, visibleMethod ) );
+void SkyMapComposite::addCustomCatalog( const QString &filename, KStarsData *data, bool (*visibleMethod)() ) {
+ CustomCatalogComponent *cc = new CustomCatalogComponent( this, filename, false, visibleMethod );
+ cc->init( data );
+ m_CustomCatalogs->addComponent( cc );
}
void SkyMapComposite::removeCustomCatalog( const QString &name ) {
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/skymapcomposite.h #768144:768145
@@ -155,7 +155,7 @@
virtual bool removeTrail( SkyObject *o );
virtual void clearTrailsExcept( SkyObject *o );
- void addCustomCatalog( const QString &filename, bool (*visibleMethod)() );
+ void addCustomCatalog( const QString &filename, KStarsData *data, bool (*visibleMethod)() );
void removeCustomCatalog( const QString &name );
bool addNameLabel( SkyObject *o );
More information about the Kstars-devel
mailing list