mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 798863 - Crash on clicking Settings button second time
Ensure that dialog resources stored in options are freed when the dialog is destroyed. The crash happened when a new dialog replaced the old one on the options and the old one's destructors tried to access a dangling reference to a GtkWidget.
This commit is contained in:
parent
50ff4a3af7
commit
4a5b897d89
@ -629,6 +629,13 @@ GncOptionsDialog::~GncOptionsDialog()
|
||||
gnc_unregister_gui_component_by_data(m_component_class, this);
|
||||
g_signal_handlers_disconnect_by_func(m_window, (gpointer)dialog_destroy_cb, this);
|
||||
g_signal_handlers_disconnect_by_func(m_window, (gpointer)dialog_window_key_press_cb, this);
|
||||
m_option_db->foreach_section([](GncOptionSectionPtr& section)
|
||||
{
|
||||
section->foreach_option([](GncOption& option)
|
||||
{
|
||||
option.set_ui_item(std::unique_ptr<GncOptionUIItem>(nullptr));
|
||||
});
|
||||
});
|
||||
g_object_unref(m_window);
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,8 @@ GncOption::set_ui_item(GncOptionUIItemPtr&& ui_item)
|
||||
return option.get_ui_type();
|
||||
}, *m_option);
|
||||
|
||||
if (ui_item->get_ui_type() != opt_ui_type)
|
||||
//ui_item may be nullptr to free the old m_ui_item.
|
||||
if (ui_item && ui_item->get_ui_type() != opt_ui_type)
|
||||
{
|
||||
PERR("Setting option %s:%s UI element failed, mismatched UI types.",
|
||||
get_section().c_str(), get_name().c_str());
|
||||
|
Loading…
Reference in New Issue
Block a user