kconfig: fix 'Save As' menu of xconfig
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Sun, 10 Mar 2019 16:13:15 +0000 (01:13 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Mon, 11 Mar 2019 17:50:24 +0000 (02:50 +0900)
The 'Save As' menu of xconfig is not working; it always saves the
kernel configuration into the default file irrespective of the file
chosen in the dialog box.

The 'Save' menu always writes into the default file, but it would
make more sense to write into the file previously chosen by 'Load'
or 'Save As'.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/kconfig/qconf.cc
scripts/kconfig/qconf.h

index 8be8a70c554284a55f46fee54652455ddf6f61e0..ce7fc87a49a7e9147ddfed74f4691d62532ed5fa 100644 (file)
@@ -1392,6 +1392,8 @@ ConfigMainWindow::ConfigMainWindow(void)
        conf_set_changed_callback(conf_changed);
        // Set saveAction's initial state
        conf_changed();
+       configname = xstrdup(conf_get_configname());
+
        QAction *saveAsAction = new QAction("Save &As...", this);
          connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs()));
        QAction *searchAction = new QAction("&Find", this);
@@ -1520,17 +1522,29 @@ ConfigMainWindow::ConfigMainWindow(void)
 
 void ConfigMainWindow::loadConfig(void)
 {
-       QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname());
-       if (s.isNull())
+       QString str;
+       QByteArray ba;
+       const char *name;
+
+       str = QFileDialog::getOpenFileName(this, "", configname);
+       if (str.isNull())
                return;
-       if (conf_read(QFile::encodeName(s)))
+
+       ba = str.toLocal8Bit();
+       name = ba.data();
+
+       if (conf_read(name))
                QMessageBox::information(this, "qconf", "Unable to load configuration!");
+
+       free(configname);
+       configname = xstrdup(name);
+
        ConfigView::updateListAll();
 }
 
 bool ConfigMainWindow::saveConfig(void)
 {
-       if (conf_write(NULL)) {
+       if (conf_write(configname)) {
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
                return false;
        }
@@ -1541,10 +1555,24 @@ bool ConfigMainWindow::saveConfig(void)
 
 void ConfigMainWindow::saveConfigAs(void)
 {
-       QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname());
-       if (s.isNull())
+       QString str;
+       QByteArray ba;
+       const char *name;
+
+       str = QFileDialog::getSaveFileName(this, "", configname);
+       if (str.isNull())
                return;
-       saveConfig();
+
+       ba = str.toLocal8Bit();
+       name = ba.data();
+
+       if (conf_write(name)) {
+               QMessageBox::information(this, "qconf", "Unable to save configuration!");
+       }
+       conf_write_autoconf(0);
+
+       free(configname);
+       configname = xstrdup(name);
 }
 
 void ConfigMainWindow::searchConfig(void)
index 41df466e67d96cfd21e294d653ba6990f48b04a8..45bfe9b2b96655833cb674f6eb72d6a9d22d6bd4 100644 (file)
@@ -291,6 +291,7 @@ protected:
 class ConfigMainWindow : public QMainWindow {
        Q_OBJECT
 
+       char *configname;
        static QAction *saveAction;
        static void conf_changed(void);
 public: