Skip to content

Fix memory leak in get_gdk_pixbuf() - #252

Closed
amaa-99 wants to merge 0 commit into
mvo5:masterfrom
amaa-99:134-fix-memory-leak-in-get_gdk_pixbuf
Closed

Fix memory leak in get_gdk_pixbuf()#252
amaa-99 wants to merge 0 commit into
mvo5:masterfrom
amaa-99:134-fix-memory-leak-in-get_gdk_pixbuf

Conversation

@amaa-99

@amaa-99 amaa-99 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Changed the gtk_icon_theme_load_icon() call to not retrieve an error object, thus avoiding the memory leak.
(closes amaa-99#134)

@amaa-99 amaa-99 changed the title Fix memory leak in get_gdk_pixbuf(): Fix memory leak in get_gdk_pixbuf() Jul 16, 2026
@amaa-99

amaa-99 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Note: GtkIconLookupFlags defines the bits of the flags bitfield, so the value 0 (no flags set) there is fine.
(Error in the declaration of that gtk function.)

Comment thread gtk/rgutils.cc Outdated

theme = gtk_icon_theme_get_default();
pixbuf = gtk_icon_theme_load_icon(theme, name, size,
(GtkIconLookupFlags)0, &error);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hm, but don't we want to keep error? And just free it after? Also this contains some whitespace changes that make reading the diff slightly harder, it would be nice to avoid those for easier review (fwiw, I think eventually we move to the fmt c-lang-format that andy is suggesting then the whole whitespace thing becomes a non-issue :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Technically handling all errors is a way to go. But in this particular case we are loading images supplied with the application itself and they suppose to be always present and be loadable.

Another option would be to get rid of this code altogether. See #257

@andy128k andy128k mentioned this pull request Jul 16, 2026
@amaa-99 amaa-99 closed this Jul 17, 2026
@amaa-99
amaa-99 force-pushed the 134-fix-memory-leak-in-get_gdk_pixbuf branch from 6dd667d to 2e3bce9 Compare July 17, 2026 19:53
@amaa-99

amaa-99 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Dropping these for now. Will re-implement after I'm back if it's still a topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix memory leak in get_gdk_pixbuf()

3 participants