Skip to content

Commit

Permalink
Adds preserve to signal created by manipulate
Browse files Browse the repository at this point in the history
Stops issues with manipulate signals being garbage collected when they go out of scope.
Fixes JuliaGizmos#115
  • Loading branch information
JobJob committed Nov 4, 2016
1 parent 522151c commit 335a1d4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/manipulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
function map_block(block, symbols)
lambda = Expr(:(->), Expr(:tuple, symbols...),
block)
:(map($lambda, $(map(s->:(signal($s)), symbols)...), typ=Any))
:(preserve(map($lambda, $(map(s->:(signal($s)), symbols)...), typ=Any)))
end

function symbols(bindings)
Expand All @@ -36,7 +36,7 @@ macro manipulate(expr)
end
syms = symbols(bindings)
Expr(:let, Expr(:block,
display_widgets(syms)...,
esc(map_block(block, syms))),
map(make_widget, bindings)...)
display_widgets(syms)...,
esc(map_block(block, syms))),
map(make_widget, bindings)...)
end

0 comments on commit 335a1d4

Please sign in to comment.