Software /
code /
prosody
Comparison
util/filters.lua @ 3135:f29a297471e3
util.filters: Don't traceback when trying to remove a filter from an uninitialized object
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 02 Jun 2010 12:24:07 +0100 |
parent | 3134:9a29ad6a9b97 |
child | 3139:7b4f180d7c6f |
comparison
equal
deleted
inserted
replaced
3134:9a29ad6a9b97 | 3135:f29a297471e3 |
---|---|
44 t_insert(filter_list, i, callback); | 44 t_insert(filter_list, i, callback); |
45 filter_list[callback] = priority; | 45 filter_list[callback] = priority; |
46 end | 46 end |
47 | 47 |
48 function remove_filter(session, type, callback) | 48 function remove_filter(session, type, callback) |
49 if not session.filters then return; end | |
49 local filter_list = session.filters[type]; | 50 local filter_list = session.filters[type]; |
50 if filter_list and filter_list[callback] then | 51 if filter_list and filter_list[callback] then |
51 for i=1, #filter_list do | 52 for i=1, #filter_list do |
52 if filter_list[i] == callback then | 53 if filter_list[i] == callback then |
53 t_remove(filter_list, i); | 54 t_remove(filter_list, i); |