mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-21 18:52:49 +00:00
Fix gtk_widget_destroy warnings
gtk_remove_widget unrefs the widget and destroys it and all its children. Since we also do that in the destructor, we do a double free. To fix this, a ref is added to prevent destroying by gtk_remove_widget.
This commit is contained in:
parent
f0d3c6c0e4
commit
eb8e0bc2b5
1 changed files with 9 additions and 4 deletions
|
@ -47,9 +47,12 @@ namespace Utils
|
|||
|
||||
Widget::~Widget()
|
||||
{
|
||||
m_Childs.clear();
|
||||
LOG("Destroy widget");
|
||||
gtk_widget_destroy(m_Widget);
|
||||
if (m_Widget)
|
||||
{
|
||||
LOG("Destroy widget and its children");
|
||||
m_Childs.clear();
|
||||
gtk_widget_destroy(m_Widget);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::CreateAndAddWidget(Widget* widget, GtkWidget* parentWidget)
|
||||
|
@ -144,8 +147,10 @@ void Widget::RemoveChild(Widget* widget)
|
|||
{
|
||||
if (m_Widget)
|
||||
{
|
||||
LOG("Remove widget from parent");
|
||||
// Ref the widget, so we don't mess up the RAII cleanup below
|
||||
g_object_ref(it->get()->m_Widget);
|
||||
gtk_container_remove((GtkContainer*)m_Widget, it->get()->m_Widget);
|
||||
it->get()->m_Widget = nullptr;
|
||||
}
|
||||
m_Childs.erase(it);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue