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

Alexey Khudyakov alexey.skladnoy at gmail.com
Mon Aug 3 23:12:23 CEST 2009


SVN commit 1006519 by khudyakov:

Use QPointer for dialog in slotEditFOV. It's the safe way to 
create modal dialogs 

CCMAIL: kstars-devel at kde.org


 M  +15 -14    fovdialog.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/dialogs/fovdialog.cpp #1006518:1006519
@@ -105,28 +105,28 @@
 }
 
 void FOVDialog::slotEditFOV() {
-    NewFOV newfdlg( this );
     //Preload current values
     FOV *f = FOVList[ currentItem() ];
 
     if (!f)
         return;
 
-    newfdlg.ui->FOVName->setText( f->name() );
-    newfdlg.ui->FOVEditX->setText( QString::number( (double)( f->sizeX() ), 'f', 2 ).replace( '.', KGlobal::locale()->decimalSymbol() ) );
-    newfdlg.ui->FOVEditY->setText( QString::number( (double)( f->sizeY() ), 'f', 2 ).replace( '.', KGlobal::locale()->decimalSymbol() ) );
-    newfdlg.ui->ColorButton->setColor( QColor( f->color() ) );
-    newfdlg.ui->ShapeBox->setCurrentIndex( f->shape() );
-    newfdlg.slotUpdateFOV();
+    QPointer<NewFOV> newfdlg = new NewFOV( this );
+    newfdlg->ui->FOVName->setText( f->name() );
+    newfdlg->ui->FOVEditX->setText( QString::number( (double)( f->sizeX() ), 'f', 2 ).replace( '.', KGlobal::locale()->decimalSymbol() ) );
+    newfdlg->ui->FOVEditY->setText( QString::number( (double)( f->sizeY() ), 'f', 2 ).replace( '.', KGlobal::locale()->decimalSymbol() ) );
+    newfdlg->ui->ColorButton->setColor( QColor( f->color() ) );
+    newfdlg->ui->ShapeBox->setCurrentIndex( f->shape() );
+    newfdlg->slotUpdateFOV();
 
-    if ( newfdlg.exec() == QDialog::Accepted ) {
-        FOV *newfov = new FOV( newfdlg.ui->FOVName->text(), 
-                               textToDouble( newfdlg.ui->FOVEditX ),
-                               textToDouble( newfdlg.ui->FOVEditY ),
-                               FOV::intToShape(newfdlg.ui->ShapeBox->currentIndex()),
-                               newfdlg.ui->ColorButton->color().name() );
+    if ( newfdlg->exec() == QDialog::Accepted ) {
+        FOV *newfov = new FOV( newfdlg->ui->FOVName->text(), 
+                               textToDouble( newfdlg->ui->FOVEditX ),
+                               textToDouble( newfdlg->ui->FOVEditY ),
+                               FOV::intToShape(newfdlg->ui->ShapeBox->currentIndex()),
+                               newfdlg->ui->ColorButton->color().name() );
 
-        fov->FOVListBox->currentItem()->setText( newfdlg.ui->FOVName->text() );
+        fov->FOVListBox->currentItem()->setText( newfdlg->ui->FOVName->text() );
 
         //Use the following replacement for QPtrList::replace():
         //(see Qt4 porting guide at doc.trolltech.com)
@@ -137,6 +137,7 @@
         fov->ViewBox->setFOV( FOVList[ currentItem() ] );
         fov->ViewBox->update();
     }
+    delete newfdlg;
 }
 
 void FOVDialog::slotRemoveFOV() {


More information about the Kstars-devel mailing list