… | |
… | |
169 | |
169 | |
170 | sub unload_extension { |
170 | sub unload_extension { |
171 | my ($pkg) = @_; |
171 | my ($pkg) = @_; |
172 | |
172 | |
173 | warn "removing extension $pkg\n"; |
173 | warn "removing extension $pkg\n"; |
|
|
174 | |
|
|
175 | if (my $cb = $pkg->can ("on_unload")) { |
|
|
176 | $cb->($pkg); |
|
|
177 | } |
174 | |
178 | |
175 | # remove hooks |
179 | # remove hooks |
176 | for my $idx (0 .. $#EVENT) { |
180 | for my $idx (0 .. $#EVENT) { |
177 | delete $hook[$idx]{$pkg}; |
181 | delete $hook[$idx]{$pkg}; |
178 | } |
182 | } |
… | |
… | |
216 | if ($who->flag (FLAG_WIZ)) { |
220 | if ($who->flag (FLAG_WIZ)) { |
217 | $who->message ("reloading..."); |
221 | $who->message ("reloading..."); |
218 | |
222 | |
219 | warn "reloading...\n"; |
223 | warn "reloading...\n"; |
220 | eval { |
224 | eval { |
|
|
225 | $_->cancel for Event::all_watchers; |
|
|
226 | |
221 | unload_extension $_ for @exts; |
227 | unload_extension $_ for @exts; |
222 | delete $INC{"cf.pm"}; |
228 | delete $INC{"cf.pm"}; |
223 | |
229 | |
224 | # don't, removes xs symbols, too |
230 | # don't, removes xs symbols, too |
225 | #Symbol::delete_package $pkg; |
231 | #Symbol::delete_package __PACKAGE__; |
226 | |
232 | |
227 | require cf; |
233 | require cf; |
228 | }; |
234 | }; |
229 | warn $@ if $@; |
235 | warn $@ if $@; |
230 | $who->message ($@) if $@; |
236 | $who->message ($@) if $@; |