Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
attempt to sprinkle sigatomic in a few places
Browse files Browse the repository at this point in the history
I think these might be places that it would try to access the Gtk stac
  • Loading branch information
vtjnash committed May 10, 2016
1 parent ecabfa1 commit 4afe9f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/GLib/GLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export signal_connect, signal_emit, signal_handler_disconnect
export signal_handler_block, signal_handler_unblock
export setproperty!, getproperty
export GConnectFlags
export @sigatom

module CompatGLib
export @assign_if_unassigned
Expand Down
9 changes: 8 additions & 1 deletion src/GLib/signals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ g_stack = nothing # need to call g_loop_run from only one stack
const g_yielded = Ref(false) # when true, use the `g_doatomic` queue to run sigatom functions
const g_doatomic = [] # (work, notification) scheduler queue
const g_sigatom_flag = Ref(false) # keep track of Base sigatomic state
function g_sigatom(f::Base.Callable) # calls f, where f never throws (but this function may throw)
function g_sigatom(f::ANY) # calls f, where f never throws (but this function may throw)
global g_sigatom_flag, g_stack, g_doatomic
prev = g_sigatom_flag[]
stk = g_stack
Expand Down Expand Up @@ -199,6 +199,13 @@ function g_sigatom(f::Base.Callable) # calls f, where f never throws (but this f
end
return ret
end
macro sigatom(f)
return quote
g_sigatom() do
$(esc(f))
end
end
end

function g_siginterruptible(f::Base.Callable, cb) # calls f (which may throw), but this function never throws
global g_sigatom_flag, g_stack
Expand Down
8 changes: 4 additions & 4 deletions src/base.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
unsafe_convert(::Type{Ptr{GObject}},w::AbstractStringLike) = unsafe_convert(Ptr{GObject},GtkLabelLeaf(w))

destroy(w::GtkWidget) = ccall((:gtk_widget_destroy,libgtk), Void, (Ptr{GObject},), w)
destroy(w::GtkWidget) = @sigatom ccall((:gtk_widget_destroy,libgtk), Void, (Ptr{GObject},), w)
parent(w::GtkWidget) = convert(GtkWidget, ccall((:gtk_widget_get_parent,libgtk), Ptr{GObject}, (Ptr{GObject},), w))
hasparent(w::GtkWidget) = ccall((:gtk_widget_get_parent,libgtk), Ptr{Void}, (Ptr{GObject},), w) != C_NULL
function toplevel(w::GtkWidget)
Expand Down Expand Up @@ -29,9 +29,9 @@ end

### Functions and methods common to all GtkWidget objects
visible(w::GtkWidget) = bool(ccall((:gtk_widget_get_visible,libgtk),Cint,(Ptr{GObject},),w))
visible(w::GtkWidget, state::Bool) = ccall((:gtk_widget_set_visible,libgtk),Void,(Ptr{GObject},Cint),w,state)
show(w::GtkWidget) = (ccall((:gtk_widget_show,libgtk),Void,(Ptr{GObject},),w); w)
showall(w::GtkWidget) = (ccall((:gtk_widget_show_all,libgtk),Void,(Ptr{GObject},),w); w)
visible(w::GtkWidget, state::Bool) = @sigatom ccall((:gtk_widget_set_visible,libgtk),Void,(Ptr{GObject},Cint),w,state)
show(w::GtkWidget) = (@sigatom ccall((:gtk_widget_show,libgtk),Void,(Ptr{GObject},),w); w)
showall(w::GtkWidget) = (@sigatom ccall((:gtk_widget_show_all,libgtk),Void,(Ptr{GObject},),w); w)

# TODO Use Pango type PangoFontDescription once it is wrapped
modifyfont(w::GtkWidget, font_desc::Ptr{Void}) =
Expand Down
6 changes: 3 additions & 3 deletions src/gio.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if gtk_version == 3
run(app::GApplication) = GLib.g_sigatom() do
ccall((:g_application_run,libgio),Cint, (Ptr{GObject},Cint, Ptr{Ptr{UInt8}}), app, 0, C_NULL)
end
run(app::GApplication) =
(@sigatom ccall((:g_application_run,libgio), Cint,
(Ptr{GObject},Cint, Ptr{Ptr{UInt8}}), app, 0, C_NULL))::Cint

function register(app::GApplication)
GError() do error_check
Expand Down

0 comments on commit 4afe9f7

Please sign in to comment.