Changeset

2828:fbddc3ed0d09

modulemanager: Fire item-removed events on module unload.
author Waqas Hussain <waqas20@gmail.com>
date Thu, 10 Dec 2009 03:02:04 +0500
parents 2827:b9df83793d84
children 2829:7f22d9c384e1
files core/modulemanager.lua
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/modulemanager.lua	Thu Dec 10 02:50:23 2009 +0500
+++ b/core/modulemanager.lua	Thu Dec 10 03:02:04 2009 +0500
@@ -197,6 +197,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;
 	return true;
 end