Diff

core/modulemanager.lua @ 2350:443e388988e7

modulemanager: Fire item-removed events on module unload.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 10 Dec 2009 03:02:04 +0500
parent 2349:e0d9f4000d6b
child 2479:9c074ba1f662
line wrap: on
line diff
--- a/core/modulemanager.lua	Thu Dec 10 03:00:16 2009 +0500
+++ b/core/modulemanager.lua	Thu Dec 10 03:02:04 2009 +0500
@@ -200,6 +200,15 @@
 		end
 	end
 	hooks:remove(host, name);
+	if mod.module.items then -- remove items
+		for key,t in pairs(mod.module.items) do
+			for i = #t,1,-1 do
+				local value = t[i];
+				t[i] = nil;
+				hosts[host].events.fire_event("item-removed/"..key, {source = self, item = value});
+			end
+		end
+	end
 	modulemap[host][name] = nil;
 	hosts[host].events.fire_event("module-unloaded", { module = name, host = host });
 	return true;