Commit 49692c0f authored by Carlos Alves's avatar Carlos Alves
Browse files

Fix crash showing Settings Dialog

When you open settings and close it, than open a new window, than
close the old window, the MainWindow with the settings will
delete the configDialog. If you try to open settings againg it crashes.

Fix is each MainWindow now has its own configDialog.

BUG: 436366
parent 242213af
......@@ -773,11 +773,17 @@ void MainWindow::showManageProfilesDialog()
void MainWindow::showSettingsDialog(const bool showProfilePage)
{
static ConfigurationDialog *confDialog = nullptr;
static KPageWidgetItem *profilePage = nullptr;
ConfigurationDialog *confDialog = findChild<ConfigurationDialog *>();
const QString profilePageName = i18nc("@title Preferences page name", "Profiles");
if (confDialog != nullptr) {
if (showProfilePage && profilePage != nullptr) {
confDialog->setCurrentPage(profilePage);
if (showProfilePage) {
for (auto page : confDialog->findChildren<KPageWidgetItem *>()) {
if (page->name().contains(profilePageName)) {
confDialog->setCurrentPage(page);
break;
}
}
}
confDialog->show();
return;
......@@ -790,8 +796,7 @@ void MainWindow::showSettingsDialog(const bool showProfilePage)
generalPage->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
confDialog->addPage(generalPage, true);
const QString profilePageName = i18nc("@title Preferences page name", "Profiles");
profilePage = new KPageWidgetItem(new ProfileSettings(confDialog), profilePageName);
auto *profilePage = new KPageWidgetItem(new ProfileSettings(confDialog), profilePageName);
profilePage->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-profiles")));
confDialog->addPage(profilePage, true);
......
......@@ -80,6 +80,8 @@ void ConfigurationDialog::addPage(KPageWidgetItem *item, bool manage)
KPageDialog::addPage(item);
item->setParent(this);
if (manage) {
_manager->addWidget(item->widget());
_groupManager->addChildren(item->widget());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment