Skip to content

Commit cee31b5

Browse files
committed
fix add_callback for empty callbacks
1 parent 21652a5 commit cee31b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/metadata.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ See also [`set_callback!`](@ref).
220220
"""
221221
function add_callback!(c::ComponentModel, cb; check=true)
222222
check && assert_cb_compat(c, cb)
223-
set_metadata!(c, :callback, (get_callbacks(c)..., cb))
223+
newcb = has_callback(c) ? (get_callbacks(c)..., cb) : (cb, )
224+
set_metadata!(c, :callback, newcb)
224225
end
225226

226227
function get_defaults(c::ComponentModel, syms; missing_val=nothing)

0 commit comments

Comments
 (0)