[Kstars-devel] branches/kstars/summer/kstars/kstars/comast

Prakash Mohan prak902000 at gmail.com
Thu Jul 30 20:42:29 CEST 2009


SVN commit 1004701 by prakash:

Fixing a crash on the execute UI that occurs when the End Session is clicked before adding the session details.

CCMAIL: kstars-devel at kde.org


 M  +22 -18    execute.cpp  


--- branches/kstars/summer/kstars/kstars/comast/execute.cpp #1004700:1004701
@@ -46,6 +46,7 @@
     currentEyepiece = NULL;
     currentLens = NULL;
     currentFilter = NULL;
+    currentSession = NULL;
 
     //initialize the global logObject
     logObject = ks->data()->logObject();
@@ -235,26 +236,29 @@
     return true;
 }
 void Execute::slotEndSession() {
-    currentSession->setSession( ui.Id->text(), geo->fullName(), ui.Begin->dateTime(), KStarsDateTime::currentDateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
-    KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "*.xml" );
-    if( fileURL.isValid() ) {
-        QFile f( fileURL.path() );
-        if( ! f.open( QIODevice::WriteOnly ) ) {
-            QString message = i18n( "Could not open file %1", f.fileName() );
-            KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
-            return;
+    if( currentSession ) {
+        currentSession->setSession( ui.Id->text(), geo->fullName(), ui.Begin->dateTime(), KStarsDateTime::currentDateTime(), ui.Weather->toPlainText(), ui.Equipment->toPlainText(), ui.Comment->toPlainText(), ui.Language->text() );
+        KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(), "*.xml" );
+        if( fileURL.isValid() ) {
+            QFile f( fileURL.path() );
+            if( ! f.open( QIODevice::WriteOnly ) ) {
+                QString message = i18n( "Could not open file %1", f.fileName() );
+                KMessageBox::sorry( 0, message, i18n( "Could Not Open File" ) );
+                return;
+            }
+            QTextStream ostream( &f );
+            ostream<< logObject->writeLog( false );
+            f.close();
         }
-        QTextStream ostream( &f );
-        ostream<< logObject->writeLog( false );
-        f.close();
     }
-    ui.Id->clear();
-    hide();
-    ui.stackedWidget->setCurrentIndex(0);
-    logObject->observationList()->clear();
-    logObject->sessionList()->clear();
-    delete currentSession;
-    currentTarget = NULL;
+        ui.Id->clear();
+        hide();
+        ui.stackedWidget->setCurrentIndex(0);
+        logObject->observationList()->clear();
+        logObject->sessionList()->clear();
+        delete currentSession;
+        currentTarget = NULL;
+        currentSession = NULL;
 }
 
 void Execute::slotSetTarget( QString name ) { 


More information about the Kstars-devel mailing list