Changeset

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
parents 2349:e0d9f4000d6b
children 2351:f8d002090cea
files core/modulemanager.lua
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
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;