allow clearing all signal handlers; allow clearing all menu item subitems

This commit is contained in:
Vadim Lopatin 2017-09-25 18:11:09 +03:00
parent 81b5175572
commit b942bdd35f
3 changed files with 19 additions and 1 deletions

View File

@ -164,6 +164,10 @@ struct Listener(RETURN_T, T1...)
final slot_t get() {
return _listener;
}
/// disconnect all listeners
final void clear() {
_listener = null;
}
alias get this;
}
@ -235,6 +239,10 @@ struct Signal(T1) if (is(T1 == interface) && __traits(allMembers, T1).length ==
final void disconnect(T1 listener) {
disconnect(&__traits(getMember, listener, __traits(allMembers, T1)[0]));
}
/// disconnect all listeners
final void clear() {
_listeners.clear();
}
}
/// Multiple listeners; implicitly specified return and parameter types
@ -287,4 +295,8 @@ struct Signal(RETURN_T, T1...)
final void disconnect(slot_t listener) {
_listeners -= listener;
}
/// disconnect all listeners
final void clear() {
_listeners.clear();
}
}

View File

@ -232,6 +232,12 @@ class MenuItem {
}
return res;
}
/// removes all subitems
void clear() {
foreach(ref item; _subitems)
item = null;
_subitems.length = 0;
}
/// returns text description for first accelerator of action; null if no accelerators
@property dstring acceleratorText() {
if (!_action)

View File

@ -1 +1 @@
v0.9.145
v0.9.146