mirror of https://github.com/buggins/dlangui.git
Ability to safe destroy widget later by event.
This commit is contained in:
parent
2433db588a
commit
4459a5f60d
|
@ -1649,6 +1649,20 @@ class RunnableEvent : CustomEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// save destroy event
|
||||||
|
class SafeDestroyEvent : RunnableEvent {
|
||||||
|
Widget _widgetToDestroy;
|
||||||
|
this (Widget widgetToDestroy)
|
||||||
|
{
|
||||||
|
_widgetToDestroy = widgetToDestroy;
|
||||||
|
super(1,null, delegate void () {
|
||||||
|
if (_widgetToDestroy.parent)
|
||||||
|
_widgetToDestroy.parent.removeChild(_widgetToDestroy);
|
||||||
|
destroy(_widgetToDestroy);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface CustomEventTarget {
|
interface CustomEventTarget {
|
||||||
/// post event to handle in UI thread (this method can be used from background thread)
|
/// post event to handle in UI thread (this method can be used from background thread)
|
||||||
void postEvent(CustomEvent event);
|
void postEvent(CustomEvent event);
|
||||||
|
|
|
@ -519,6 +519,12 @@ class Window : CustomEventTarget {
|
||||||
destroy(_timerQueue);
|
destroy(_timerQueue);
|
||||||
_eventList = null;
|
_eventList = null;
|
||||||
}
|
}
|
||||||
|
/// safe destroy widget
|
||||||
|
void safeWidgetDestroy(Widget widgetToDestroy)
|
||||||
|
{
|
||||||
|
SafeDestroyEvent ev = new SafeDestroyEvent(widgetToDestroy);
|
||||||
|
postEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
private void animate(Widget root, long interval) {
|
private void animate(Widget root, long interval) {
|
||||||
if (root is null)
|
if (root is null)
|
||||||
|
|
Loading…
Reference in New Issue