bool GView::Detach() { ThreadCheck(); // Detach view if (_Window) { GWindow *Wnd = dynamic_cast<GWindow*>(_Window); if (Wnd) Wnd->SetFocus(this, GWindow::ViewDelete); _Window = NULL; } GViewI *Par = GetParent(); if (Par) { // Events Par->DelView(this); Par->OnChildrenChanged(this, false); } d->Parent = 0; d->ParentI = 0; { int Count = Children.Length(); if (Count) { int Detached = 0; GViewI *c, *prev = NULL; while (c = Children.First()) { LgiAssert(!prev || c != prev); if (c->GetParent()) c->Detach(); else Children.Delete(c); Detached++; prev = c; } LgiAssert(Count == Detached); } } if (_View) { LgiAssert(_View->object.parent_instance.g_type_instance.g_class); gtk_widget_destroy(_View); _View = 0; } return true; }
void GView::_Delete() { ThreadCheck(); SetPulse(); // Remove static references to myself if (_Over == this) _Over = 0; if (_Capturing == this) _Capturing = 0; GWindow *Wnd = GetWindow(); if (Wnd && Wnd->GetFocus() == static_cast<GViewI*>(this)) Wnd->SetFocus(this, GWindow::ViewDelete); if (LgiApp && LgiApp->AppWnd == this) { LgiApp->AppWnd = 0; } // Misc Pos.ZOff(-1, -1); // Heirarchy GViewI *c; while (c = Children.First()) { if (c->GetParent() != (GViewI*)this) { printf("%s:%i - ~GView error, %s not attached correctly: %p(%s) Parent: %p(%s)\n", _FL, c->GetClass(), c, c->Name(), c->GetParent(), c->GetParent() ? c->GetParent()->Name() : ""); Children.Delete(c); } DeleteObj(c); } Detach(); LgiAssert(_View == NULL); }