From: Mikko Rasa Date: Mon, 28 Feb 2011 15:22:39 +0000 (+0000) Subject: Avoid generating events during destruction of a widget X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=033732b500a35f3737bad515349d884cb3f123f0;p=libs%2Fgltk.git Avoid generating events during destruction of a widget --- diff --git a/source/widget.cpp b/source/widget.cpp index 17bc4e3..a5a0f2d 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -30,7 +30,11 @@ Widget::Widget(): Widget::~Widget() { if(parent) - parent->remove(*this); + { + Container *p = parent; + parent = 0; + p->remove(*this); + } } void Widget::set_position(int x, int y) @@ -70,6 +74,8 @@ void Widget::set_parent(Container *p) { if(parent && p) throw InvalidState("Widget is already in a Container"); + else if(p==parent) + return; parent = p; on_reparent();