idanarye / woab

Widgets on Actors Bridge - a GUI microframework for combining GTK with Actix
https://crates.io/crates/woab
MIT License
14 stars 1 forks source link

A weird segfault #37

Closed piegamesde closed 3 years ago

piegamesde commented 3 years ago

I already ran into this several months ago, but I had too many other things to deal with for reporting (and I hoped that some refactorings would make it go away). Anyways:

My application has a window (gtk::ApplicationWindow), and I externally create a gtk::Application. I link them using:

window.set_application(Some(&application));

The weird fact is, that it matters where I call that function. If I call it within my original initialization (now in woab::block_on), it works fine. But if I call it within the started method of my main actor, it sefaults for some reason. It is only a minor annoyance once you know the workaround (I still think that line would be better off in started, but eeh), but initially it took me quite a lot of time to figure out.

Let me know if you can reproduce this, otherwise I'll try to provide a minimized example.

idanarye commented 3 years ago

I've managed to replicate it: https://gist.github.com/idanarye/50bf4833c6968980c3c891b756dec8df/38430ef9c90687b26db83cded70a5b26e5698a7e

The problem is that GTK segfaults if you are trying to set the application window outside the activate signal. Note that in the gist I'm creating the actor inside connect_activate - but apparently Actix will not run its started method yet. By the time Actix runs it, the activate signal is already over.

idanarye commented 3 years ago

Possible solution - use woab::route_signal instead of connect_activate: https://gist.github.com/idanarye/50bf4833c6968980c3c891b756dec8df/6b5b9f7a3c10e7d16fd9b54c546cf22da328fb64

idanarye commented 3 years ago

Either way, this is something that deserves a mention under Pitfalls.