]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
kconfig: qconf: use QString to store path to configuration file
authorRolf Eike Beer <eb@emlix.com>
Wed, 23 Oct 2024 06:31:46 +0000 (08:31 +0200)
committerMasahiro Yamada <masahiroy@kernel.org>
Tue, 5 Nov 2024 23:46:34 +0000 (08:46 +0900)
This is the native type used by the file dialogs and avoids any hassle with
filename encoding when converting this back and forth to a character array.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/qconf.cc
scripts/kconfig/qconf.h

index 7bac48ac5d21bbf61544c5c3f1e6d6778569a3fd..b620efac7da02a1ddca4f19e4521ca2ec4202edc 100644 (file)
@@ -1381,7 +1381,7 @@ ConfigMainWindow::ConfigMainWindow(void)
 
        conf_set_changed_callback(conf_changed);
 
-       configname = xstrdup(conf_get_configname());
+       configname = conf_get_configname();
 
        QAction *saveAsAction = new QAction("Save &As...", this);
        connect(saveAsAction, &QAction::triggered,
@@ -1520,28 +1520,22 @@ ConfigMainWindow::ConfigMainWindow(void)
 void ConfigMainWindow::loadConfig(void)
 {
        QString str;
-       QByteArray ba;
-       const char *name;
 
        str = QFileDialog::getOpenFileName(this, "", configname);
        if (str.isNull())
                return;
 
-       ba = str.toLocal8Bit();
-       name = ba.data();
-
-       if (conf_read(name))
+       if (conf_read(str.toLocal8Bit().constData()))
                QMessageBox::information(this, "qconf", "Unable to load configuration!");
 
-       free(configname);
-       configname = xstrdup(name);
+       configname = str;
 
        ConfigList::updateListAllForAll();
 }
 
 bool ConfigMainWindow::saveConfig(void)
 {
-       if (conf_write(configname)) {
+       if (conf_write(configname.toLocal8Bit().constData())) {
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
                return false;
        }
@@ -1553,23 +1547,17 @@ bool ConfigMainWindow::saveConfig(void)
 void ConfigMainWindow::saveConfigAs(void)
 {
        QString str;
-       QByteArray ba;
-       const char *name;
 
        str = QFileDialog::getSaveFileName(this, "", configname);
        if (str.isNull())
                return;
 
-       ba = str.toLocal8Bit();
-       name = ba.data();
-
-       if (conf_write(name)) {
+       if (conf_write(str.toLocal8Bit().constData())) {
                QMessageBox::information(this, "qconf", "Unable to save configuration!");
        }
        conf_write_autoconf(0);
 
-       free(configname);
-       configname = xstrdup(name);
+       configname = str;
 }
 
 void ConfigMainWindow::searchConfig(void)
index 53373064d90ace9cc779482b16004897c93d0519..aab25ece95c6472218a58424449bdd193aa1a035 100644 (file)
@@ -237,7 +237,7 @@ protected:
 class ConfigMainWindow : public QMainWindow {
        Q_OBJECT
 
-       char *configname;
+       QString configname;
        static QAction *saveAction;
        static void conf_changed(bool);
 public: