xconfig: Abort close if configuration cannot be saved
authorMichal Marek <mmarek@suse.cz>
Wed, 25 May 2011 13:10:25 +0000 (15:10 +0200)
committerMichal Marek <mmarek@suse.cz>
Mon, 25 Jul 2011 13:50:34 +0000 (15:50 +0200)
Give the user an opportunity to fix the error or save the configuration
under a different path.

Reported-by: Hiromu Yakura <hiromu1996@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/kconfig/qconf.cc
scripts/kconfig/qconf.h

index 31e01cdbfc6ea11dde098c26b5bc08624a591968..df274febb3e51d6331c5b64e4f29a64f51817538 100644 (file)
@@ -1478,10 +1478,13 @@ void ConfigMainWindow::loadConfig(void)
        ConfigView::updateListAll();
 }
 
-void ConfigMainWindow::saveConfig(void)
+bool ConfigMainWindow::saveConfig(void)
 {
-       if (conf_write(NULL))
+       if (conf_write(NULL)) {
                QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+               return false;
+       }
+       return true;
 }
 
 void ConfigMainWindow::saveConfigAs(void)
@@ -1642,7 +1645,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
        mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
        switch (mb.exec()) {
        case QMessageBox::Yes:
-               saveConfig();
+               if (saveConfig())
+                       e->accept();
+               else
+                       e->ignore();
+               break;
        case QMessageBox::No:
                e->accept();
                break;
index 91677d900dbd0aa68e07ca74a90709d5182edcf5..3715b3e7212c9adccdc25483e632487a64360b54 100644 (file)
@@ -311,7 +311,7 @@ public slots:
        void listFocusChanged(void);
        void goBack(void);
        void loadConfig(void);
-       void saveConfig(void);
+       bool saveConfig(void);
        void saveConfigAs(void);
        void searchConfig(void);
        void showSingleView(void);