Skip to content

Commit cdb37fe

Browse files
DerDakonmasahir0y
authored andcommitted
kconfig: qconf: use QString to store path to configuration file
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 <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent cdb1e76 commit cdb37fe

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

scripts/kconfig/qconf.cc

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ ConfigMainWindow::ConfigMainWindow(void)
13811381

13821382
conf_set_changed_callback(conf_changed);
13831383

1384-
configname = xstrdup(conf_get_configname());
1384+
configname = conf_get_configname();
13851385

13861386
QAction *saveAsAction = new QAction("Save &As...", this);
13871387
connect(saveAsAction, &QAction::triggered,
@@ -1520,28 +1520,22 @@ ConfigMainWindow::ConfigMainWindow(void)
15201520
void ConfigMainWindow::loadConfig(void)
15211521
{
15221522
QString str;
1523-
QByteArray ba;
1524-
const char *name;
15251523

15261524
str = QFileDialog::getOpenFileName(this, "", configname);
15271525
if (str.isNull())
15281526
return;
15291527

1530-
ba = str.toLocal8Bit();
1531-
name = ba.data();
1532-
1533-
if (conf_read(name))
1528+
if (conf_read(str.toLocal8Bit().constData()))
15341529
QMessageBox::information(this, "qconf", "Unable to load configuration!");
15351530

1536-
free(configname);
1537-
configname = xstrdup(name);
1531+
configname = str;
15381532

15391533
ConfigList::updateListAllForAll();
15401534
}
15411535

15421536
bool ConfigMainWindow::saveConfig(void)
15431537
{
1544-
if (conf_write(configname)) {
1538+
if (conf_write(configname.toLocal8Bit().constData())) {
15451539
QMessageBox::information(this, "qconf", "Unable to save configuration!");
15461540
return false;
15471541
}
@@ -1553,23 +1547,17 @@ bool ConfigMainWindow::saveConfig(void)
15531547
void ConfigMainWindow::saveConfigAs(void)
15541548
{
15551549
QString str;
1556-
QByteArray ba;
1557-
const char *name;
15581550

15591551
str = QFileDialog::getSaveFileName(this, "", configname);
15601552
if (str.isNull())
15611553
return;
15621554

1563-
ba = str.toLocal8Bit();
1564-
name = ba.data();
1565-
1566-
if (conf_write(name)) {
1555+
if (conf_write(str.toLocal8Bit().constData())) {
15671556
QMessageBox::information(this, "qconf", "Unable to save configuration!");
15681557
}
15691558
conf_write_autoconf(0);
15701559

1571-
free(configname);
1572-
configname = xstrdup(name);
1560+
configname = str;
15731561
}
15741562

15751563
void ConfigMainWindow::searchConfig(void)

scripts/kconfig/qconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public slots:
237237
class ConfigMainWindow : public QMainWindow {
238238
Q_OBJECT
239239

240-
char *configname;
240+
QString configname;
241241
static QAction *saveAction;
242242
static void conf_changed(bool);
243243
public:

0 commit comments

Comments
 (0)