Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions cfg/gtk.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,6 @@
<alloc init="true" no-fail="true">g_zlib_decompressor_new</alloc>
<use>g_object_ref</use>
<dealloc>g_object_unref</dealloc>
<dealloc>gtk_widget_destroy</dealloc>
</memory>
<memory>
<alloc init="true" no-fail="true">g_tree_new</alloc>
Expand All @@ -1019,6 +1018,11 @@
<use>g_file_attribute_matcher_ref</use>
<dealloc>g_file_attribute_matcher_unref</dealloc>
</memory>
<memory>
<alloc init="true" no-fail="true">gtk_window_new</alloc>
<dealloc>gtk_widget_destroy</dealloc>
<dealloc>gtk_window_destroy</dealloc>
</memory>
<function name="g_application_get_default">
<leak-ignore/>
<noreturn>false</noreturn>
Expand Down Expand Up @@ -9787,6 +9791,14 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<!-- gtk3: GtkWidget * gtk_window_new(GtkWindowType type)
gtk4: GtkWidget * gtk_window_new() -->
<function name="gtk_window_new">
<noreturn>false</noreturn>
<use-retval/>
<returnValue type="GtkWidget *"/>
<arg nr="1" direction="in" default="0"/>
</function>
<function name="gtk_window_list_toplevels">
<leak-ignore/>
<noreturn>false</noreturn>
Expand Down Expand Up @@ -21229,10 +21241,6 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<function name="gtk_widget_destroy">
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<function name="gtk_widget_destroyed">
<leak-ignore/>
<noreturn>false</noreturn>
Expand Down Expand Up @@ -21889,6 +21897,13 @@
<leak-ignore/>
<noreturn>false</noreturn>
</function>
<function name="gtk_window_destroy">
<noreturn>false</noreturn>
<returnValue type="void"/>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<function name="gtk_window_fullscreen">
<leak-ignore/>
<noreturn>false</noreturn>
Expand Down Expand Up @@ -23070,6 +23085,9 @@
<define name="GTK_LEVEL_BAR_OFFSET_FULL" value="&quot;full&quot;"/>
<define name="GTK_LEVEL_BAR_OFFSET_HIGH" value="&quot;high&quot;"/>
<define name="GTK_LEVEL_BAR_OFFSET_LOW" value="&quot;low&quot;"/>
<!-- gtk/gtkwindow.h -->
<define name="GTK_WINDOW_TOPLEVEL" value="0"/>
<define name="GTK_WINDOW_POPUP" value="1"/>
<!-- gtk/gtk.h -->
<define name="GTK_STOCK_ZOOM_IN" value="&quot;gtk-zoom-in&quot;"/>
<define name="GTK_STOCK_ZOOM_FIT" value="&quot;gtk-zoom-fit&quot;"/>
Expand Down
11 changes: 11 additions & 0 deletions test/cfg/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,14 @@ void g_tree_test() {
printf("%p\n", tree2);
// cppcheck-suppress memleak
}

void gtk_widget_destroy_test() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This testing does not enforce that these functions have any <alloc> configuration at all. I think you should have a test where it leaks. And a test with mismatching gtk allocation and deallocation would also be good to ensure the groups are proper.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, if I comment out the call to gtk_widget_destroy, there is no memory leak, and I don't understand why.

Copy link
Copy Markdown
Collaborator

@chrchr-github chrchr-github May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like gtk_window_new() cannot be matched. This should work in gtk.cfg: <arg nr="1" direction="in" default="0"/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works, thanks!

GtkWidget *widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(widget);
// cppcheck-suppress memleak

widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(widget);
// cppcheck-suppress mismatchAllocDealloc
g_object_unref(widget);
}
Loading