diff --git a/src/YabInterface.cpp b/src/YabInterface.cpp index 56a66c8..e06ff7a 100644 --- a/src/YabInterface.cpp +++ b/src/YabInterface.cpp @@ -391,18 +391,7 @@ int YabInterface::CloseWindow(const char* view) yabcanvas->RemoveItem(child); // viewList->PrintOut(); - BView *subchild; - if(subchild = child->ChildAt(0)) - while(subchild) - { - CleanupYabTabView(subchild); - if(viewList->GetView(subchild->Name())) - { - RemoveView(subchild); - viewList->DelView(subchild->Name()); - } - subchild = subchild->NextSibling(); - } + CleanupSubchildView(child->ChildAt(0)); if(viewList->GetView(child->Name())) { RemoveView(child); @@ -3366,18 +3355,7 @@ void YabInterface::WindowClear(const char* window) CleanupYabTabView(child); if(is_kind_of(child, YabBitmapView)) yabcanvas->RemoveItem(child); - BView *subchild; - if(subchild = child->ChildAt(0)) - while(subchild) - { - CleanupYabTabView(subchild); - if(viewList->GetView(subchild->Name())) - { - RemoveView(subchild); - viewList->DelView(subchild->Name()); - } - subchild = subchild->NextSibling(); - } + CleanupSubchildView(child->ChildAt(0)); if(viewList->GetView(child->Name())) { RemoveView(child); @@ -3429,18 +3407,7 @@ void YabInterface::RemoveView(BView *myView) CleanupYabTabView(child); if(is_kind_of(child, YabBitmapView)) yabcanvas->RemoveItem(child); - BView *subchild; - if(subchild = child->ChildAt(0)) - while(subchild) - { - CleanupYabTabView(subchild); - if(viewList->GetView(subchild->Name())) - { - RemoveView(subchild); - viewList->DelView(subchild->Name()); - } - subchild = subchild->NextSibling(); - } + CleanupSubchildView(child->ChildAt(0)); if(viewList->GetView(child->Name())) { RemoveView(child); @@ -3493,6 +3460,22 @@ void YabInterface::CleanupYabTabView(BView* view) } } +void YabInterface::CleanupSubchildView(BView* view) +{ + if(view == NULL || viewList == NULL) return; + + while(view) + { + CleanupYabTabView(view); + if(viewList->GetView(view->Name())) + { + RemoveView(view); + viewList->DelView(view->Name()); + } + view = view->NextSibling(); + } +} + void YabInterface::TextEdit(BRect frame, const char* title, int scrollbar, const char* window) { YabView *myView = cast_as((BView*)viewList->GetView(window), YabView); diff --git a/src/YabInterface.h b/src/YabInterface.h index 96943a8..8c6dbd5 100644 --- a/src/YabInterface.h +++ b/src/YabInterface.h @@ -249,6 +249,7 @@ BBitmap* loadImage(const char* name); static int compare(BListItem **firstArg, BListItem **secondArg); void CleanupYabTabView(BView* view); + void CleanupSubchildView(BView* view); BTranslatorRoster *Roster; char ApplicationDirectory[1024];