Gui: handle std::exception and Base::Exception inside DlgPreferencesImp::createPageInGroup to avoid that the preferences dialog won't be shown at all

This commit is contained in:
wmayer
2022-11-06 14:05:01 +01:00
committed by Uwe
parent a36c87c71d
commit 9647ac5fdd
+17 -8
View File
@@ -176,15 +176,24 @@ QTabWidget* DlgPreferencesImp::createTabForGroup(const std::string &groupName)
*/
void DlgPreferencesImp::createPageInGroup(QTabWidget *tabWidget, const std::string &pageName)
{
PreferencePage* page = WidgetFactory().createPreferencePage(pageName.c_str());
if (page) {
tabWidget->addTab(page, page->windowTitle());
page->loadSettings();
page->setProperty("GroupName", tabWidget->property("GroupName"));
page->setProperty("PageName", QVariant(QString::fromStdString(pageName)));
try {
PreferencePage* page = WidgetFactory().createPreferencePage(pageName.c_str());
if (page) {
tabWidget->addTab(page, page->windowTitle());
page->loadSettings();
page->setProperty("GroupName", tabWidget->property("GroupName"));
page->setProperty("PageName", QVariant(QString::fromStdString(pageName)));
}
else {
Base::Console().Warning("%s is not a preference page\n", pageName.c_str());
}
}
else {
Base::Console().Warning("%s is not a preference page\n", pageName.c_str());
catch (const Base::Exception& e) {
Base::Console().Error("Base exception thrown for '%s'\n", pageName.c_str());
e.ReportException();
}
catch (const std::exception& e) {
Base::Console().Error("C++ exception thrown for '%s' (%s)\n", pageName.c_str(), e.what());
}
}