gtkd-developers / GtkD

GtkD is a D binding and OO wrapper of GTK+ originally created by Antonio Monteiro
http://gtkd.org
Other
322 stars 71 forks source link

Image contructor segfault #252

Closed JoeKays closed 6 years ago

JoeKays commented 6 years ago

Hi,

when doing ThemedIcon tIcon = new ThemedIcon("folder-publicshare-symbolic"); Image img = new Image(tIcon, GtkIconSize.DND); or Image img = new Image("folder-publicshare-symbolic", GtkIconSize.DND); I get a segfault with gdb indicating the issue in Image.d: 320 auto p = gtk_image_new_from_icon_name(Str.toStringz(iconName), size); Anyone else with this issue? I tried several icon sizes and icon names and made sure the icon was present in my icon theme (Linux).

MikeWey commented 6 years ago

I'm not able to reproduce this issue locally, what compiler and version of GTK and gtkD are you using?

JoeKays commented 6 years ago

Interesting. Might be a problem with my particular installation. I am on Debian buster with gtkd 3.8.3 and gtk 3.24.1-2.

JoeKays commented 6 years ago

Ok, so I tried it with dmd and ldc2 now and the issue persists. Trying on a different system with a clean project now...

JoeKays commented 6 years ago

Yep, also throws in a clean project with dmd and ldc2. Gdc does not compile with some really long and weird linker error: gtk-d-3.8.3/gtk-d/generated/sourceview/gsv/Region.d:1: multiple definition of _DT32_D3gtk6Widget6Widget10__mixin37620getImplementorStructMFbZPS3atk1c5types14AtkImplementor ... Not sure what this means...

JoeKays commented 6 years ago

Update: After some fiddling I noticed, that the segfault also occurs in the Image classes standard constructor. Then the error is in Image.d:197: auto p = gtk_image_new(); So this issue seems to be a general Image class issue with my gtk version. Does this even have anything to do with gtkd?

JoeKays commented 6 years ago

Ok, so I tried it with a simple C++ program and it does not segfault. However I get Gtk-CRITICAL **: gtk_image_set_from_icon_name: assertion 'GTK_IS_IMAGE (image)' failed output when calling gtk_image_set_from_icon_name(...). Not sure if this has anything to do with it since with gtkd it segfaults in the default constructor already.

MikeWey commented 6 years ago

I tried reproducing the issue a vm with debian buster, but it's still working for me.

Could you share a (trimmed down) example that has the issue?

JoeKays commented 6 years ago

Weird. The trimmed down example would be: app.d: import gtk.Image; void main() { Image img = new Image(); } dub.json: { "name": "gtktest", "dependencies": { "gtk-d": "~>3.8.3" } } That's it. Already segfaults for me. Really strange. Edit: Gdb output is something like:

segfault in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0

MikeWey commented 6 years ago

You will need to initialize the gtk runtime before using it.

You can either call gtk.Main.Main.init which is deprecated on the gtk side, or use gtk.Application, see the HelloWorld demo for a simple gtk.Application example.

I can reproduce the issue when using the exact code you posted, but for me the segfault is gone when the runtime is initialized.

JoeKays commented 6 years ago

Oh, holy crap! That is the issue for sure. Now I remember that I removed this part of the code, because in my use case I didn't even have a GUI application and only needed gtkd for the file icon handling. Guess that way I forgot that gtk has to be initialized. Shame... I guess we can close this and apologies for the wasted time!