Skip to content

Commit 8741908

Browse files
committed
kconfig: fix 'Save As' menu of xconfig
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>
1 parent 769a1c0 commit 8741908

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

scripts/kconfig/qconf.cc

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,8 @@ ConfigMainWindow::ConfigMainWindow(void)
13921392
conf_set_changed_callback(conf_changed);
13931393
// Set saveAction's initial state
13941394
conf_changed();
1395+
configname = xstrdup(conf_get_configname());
1396+
13951397
QAction *saveAsAction = new QAction("Save &As...", this);
13961398
connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs()));
13971399
QAction *searchAction = new QAction("&Find", this);
@@ -1520,17 +1522,29 @@ ConfigMainWindow::ConfigMainWindow(void)
15201522

15211523
void ConfigMainWindow::loadConfig(void)
15221524
{
1523-
QString s = QFileDialog::getOpenFileName(this, "", conf_get_configname());
1524-
if (s.isNull())
1525+
QString str;
1526+
QByteArray ba;
1527+
const char *name;
1528+
1529+
str = QFileDialog::getOpenFileName(this, "", configname);
1530+
if (str.isNull())
15251531
return;
1526-
if (conf_read(QFile::encodeName(s)))
1532+
1533+
ba = str.toLocal8Bit();
1534+
name = ba.data();
1535+
1536+
if (conf_read(name))
15271537
QMessageBox::information(this, "qconf", "Unable to load configuration!");
1538+
1539+
free(configname);
1540+
configname = xstrdup(name);
1541+
15281542
ConfigView::updateListAll();
15291543
}
15301544

15311545
bool ConfigMainWindow::saveConfig(void)
15321546
{
1533-
if (conf_write(NULL)) {
1547+
if (conf_write(configname)) {
15341548
QMessageBox::information(this, "qconf", "Unable to save configuration!");
15351549
return false;
15361550
}
@@ -1541,10 +1555,24 @@ bool ConfigMainWindow::saveConfig(void)
15411555

15421556
void ConfigMainWindow::saveConfigAs(void)
15431557
{
1544-
QString s = QFileDialog::getSaveFileName(this, "", conf_get_configname());
1545-
if (s.isNull())
1558+
QString str;
1559+
QByteArray ba;
1560+
const char *name;
1561+
1562+
str = QFileDialog::getSaveFileName(this, "", configname);
1563+
if (str.isNull())
15461564
return;
1547-
saveConfig();
1565+
1566+
ba = str.toLocal8Bit();
1567+
name = ba.data();
1568+
1569+
if (conf_write(name)) {
1570+
QMessageBox::information(this, "qconf", "Unable to save configuration!");
1571+
}
1572+
conf_write_autoconf(0);
1573+
1574+
free(configname);
1575+
configname = xstrdup(name);
15481576
}
15491577

15501578
void ConfigMainWindow::searchConfig(void)

scripts/kconfig/qconf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ public slots:
291291
class ConfigMainWindow : public QMainWindow {
292292
Q_OBJECT
293293

294+
char *configname;
294295
static QAction *saveAction;
295296
static void conf_changed(void);
296297
public:

0 commit comments

Comments
 (0)