-
Notifications
You must be signed in to change notification settings - Fork 80
Issue with sigatom #391
Comments
I think that's the correct way to do that: using GtkExtensions
using Gtk.ShortNames
using Dates
b = Box(:v)
win = Window(b,"test")
ent = Entry()
push!(b,ent)
button = Button("ok")
push!(b,button)
Gtk.showall(win)
function update_cb!(user_data)
ent = unsafe_pointer_to_objref(user_data)
set_gtk_property!(ent, :text, "$(Dates.now())")
Cint(true)#keep running
end
g_timeout_add(100,update_cb!,ent) #do every 100ms
signal_connect(button, "clicked") do widget
set_gtk_property!(button, :label, "$(rand(1:10))")
end using this https://github.com/jonathanBieler/GtkExtensions.jl/blob/master/src/GtkExtensions.jl#L337 |
If I remove "@sigatom" from something that changes the UI (set*) I get segfaults. |
I never use using GtkExtensions
using Gtk.ShortNames
using Dates
b = Box(:v)
win = Window(b,"test")
ent = Entry()
push!(b,ent)
button = Button("ok")
push!(b,button)
Gtk.showall(win)
function update_cb!(user_data)
ent = unsafe_pointer_to_objref(user_data)
Gtk.@sigatom begin
set_gtk_property!(ent, :text, "$(Dates.now())")
end
Cint(true)#keep running
end
g_timeout_add(100,update_cb!,ent) #do every 100ms
signal_connect(button, "clicked") do widget
Gtk.@sigatom begin
set_gtk_property!(button, :label, "$(rand(1:10))")
end
end |
Can you add a sleep to your original example? |
It works fine with a sleep, it blocks the application for 0.1 second though. |
I cannot test your code in Julia 1.0 since |
Regarding sleep just try my original example and remove the |
Yes, I think the underlying problem is that it's not safe to interact with Gtk components outside of Gtk's main loop. As I understand |
Could you add that function to Gtk.jl? It is in GLib so it fits. |
I will yes, I have a bunch of stuff in GtkExtensions that should be in Gtk but I haven't had time to move them yet. Maybe having a look at what other languages do with this would be useful (it seems like Python also has this idle_add). |
yes looking into how other languages do this is a good thing. While my original is a valid use case, what I also would like is to have some heavy computation in the background while the UI is still responsive. For now I have solve this by braking my computation into chunks and using a task for it that always waits between the chunks. |
On julia 1.1 the following code does not segfault anymore:
|
@vtjnash: I introduced a macro https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-timeout-add After removing |
I'm not using |
This is now coming up in the GtkObservables tests, specifically Line 174 in 69c1080
Any ideas of how best to handle this? My knowledge of this part of the code is pretty minimal. |
This is a work-around for JuliaGraphics/Gtk.jl#391 (comment)
There's a workaround in JuliaGizmos/GtkObservables.jl#30 |
This is a work-around for JuliaGraphics/Gtk.jl#391 (comment)
We should probably just remove it. The only important location I just found was this: Line 1 in 543a4f1
|
That seems like a big one, though! |
Yes, indeed. It's the one that wraps everything. |
Dear @vtjnash,
There is still a major limitation of the Julia Gtk bindings compared to other language bindings. Its that one can only do one thing at a time. I get
if I execute the following test program:
You have to click on the button to see the crash.
The example is of course constructed but appears in a real application of mine. The sleep is actually a computation that takes some time.
It would be absolutely awesome if we could find a solution to this problem. Do you think JuliaLang/julia#13099 would solve this, if I just remove sigatom?
The text was updated successfully, but these errors were encountered: