Skip to content

Commit

Permalink
Also give better reporting for error-on-execution
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Aug 29, 2015
1 parent 89acb2a commit 2c3d978
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/GLib/signals.jl
Expand Up @@ -88,7 +88,7 @@ function GClosureMarshal(closuref, return_value, n_param_values,
end
end
local retval = nothing
g_siginterruptible() do
g_siginterruptible(cb) do
# note: make sure not to leak any of the GValue objects into this task switch, since many of them were alloca'd
retval = cb(params...) # widget, args...
end
Expand All @@ -98,18 +98,22 @@ function GClosureMarshal(closuref, return_value, n_param_values,
try
return_value[] = gvalue(retval)
catch
if isgeneric(cb)
warn("Executing ", cb, ":")
else
warn("Executing ", Base.uncompressed_ast(cb.code).args[3].args[1]) # just show file/line
end
blame(cb)
error("Error setting return value of type $(typeof(retval)); did your callback return an unintentional value?")
end
end
end
return nothing
end

function blame(cb)
if isgeneric(cb)
warn("Executing ", cb, ":")
else
warn("Executing ", Base.uncompressed_ast(cb.code).args[3].args[1]) # just show file/line
end
end

# Signals API for the cb pointer
# Gtk 2
# https://developer.gnome.org/gtk2/stable/GObject.html#GObject-destroy
Expand Down Expand Up @@ -210,7 +214,7 @@ else
_get_return() = current_task().last
end

function g_siginterruptible(f::Base.Callable)
function g_siginterruptible(f::Base.Callable, cb)
global g_sigatom_flag, gtk_stack, gtk_work
prev = g_sigatom_flag
@assert prev $ (current_task() !== gtk_stack)
Expand Down Expand Up @@ -280,6 +284,7 @@ function g_siginterruptible(f::Base.Callable)
end
end
catch err
blame(cb)
ct = current_task()
filter!(x->x!==ct, Base.Workqueue)
if f !== yield
Expand Down Expand Up @@ -387,7 +392,7 @@ function uv_dispatch{T}(src::Ptr{Void},callback::Ptr{Void},data::T)
end

function g_yield(data)
g_siginterruptible(yield)
g_siginterruptible(yield, yield)
return int32(true)
end

Expand Down

0 comments on commit 2c3d978

Please sign in to comment.