Comparison

core/modulemanager.lua @ 4604:eef5e3a83792

modulemanager: Use appropriate events object for global modules when firing item-removed on unload
author Matthew Wild <mwild1@gmail.com>
date Wed, 14 Mar 2012 17:03:48 +0000
parent 4565:5a2212d3468e
child 4606:17785dbd9d58
comparison
equal deleted inserted replaced
4603:6900c9484834 4604:eef5e3a83792
99 for handler, event in pairs(mod.module.event_handlers) do 99 for handler, event in pairs(mod.module.event_handlers) do
100 event.object.remove_handler(event.name, handler); 100 event.object.remove_handler(event.name, handler);
101 end 101 end
102 102
103 if mod.module.items then -- remove items 103 if mod.module.items then -- remove items
104 local events = (host == "*" and prosody.events) or hosts[host].events;
104 for key,t in pairs(mod.module.items) do 105 for key,t in pairs(mod.module.items) do
105 for i = #t,1,-1 do 106 for i = #t,1,-1 do
106 local value = t[i]; 107 local value = t[i];
107 t[i] = nil; 108 t[i] = nil;
108 hosts[host].events.fire_event("item-removed/"..key, {source = mod.module, item = value}); 109 events.fire_event("item-removed/"..key, {source = mod.module, item = value});
109 end 110 end
110 end 111 end
111 end 112 end
112 modulemap[host][name] = nil; 113 modulemap[host][name] = nil;
113 return true; 114 return true;