This prevents an inconsistent state from forming if something goes wrong.
throw hierarchy_error("widget already parented");
else if(p==parent)
return;
- parent = p;
- on_reparent();
- update_style();
+ try
+ {
+ parent = p;
+
+ on_reparent();
+ update_style();
+ }
+ catch(...)
+ {
+ // The container has not yet added the widget as its child
+ parent = 0;
+ throw;
+ }
}
void Widget::set_style(const string &s)