From f2b36ed7f899785b14f04d2a0cf2439fd3f916de Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Fri, 2 Dec 2022 10:16:33 +0100 Subject: [PATCH] =?UTF-8?q?When=20Poping=20views,=20make=20sure=20we=20add?= =?UTF-8?q?=20the=20targeted=20one=20if=20we=20couldn=E2=80=99t=20already?= =?UTF-8?q?=20find=20it=20in=20the=20stack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/PhoneMainView.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index df6b3617f..e3029d004 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -640,7 +640,6 @@ static RootViewManager *rootViewManagerInstance = nil; animated:(BOOL)animated addViewToStack:(BOOL)addViewToStack { PhoneMainView *vc = [[RootViewManager instance] setViewControllerForDescription:view]; - LOGI(@"_changeCurrentView : stack size before = %d", [RootViewManager instance].viewDescriptionStack.count); if (![view equal:vc.currentView] || vc != self) { LOGI(@"Change current view to %@", view.name); [self setPreviousViewName:vc.currentView.name]; @@ -652,7 +651,6 @@ static RootViewManager *rootViewManagerInstance = nil; [vc.mainViewController changeView:view]; vc->currentView = view; } - LOGI(@"_changeCurrentView : stack size after = %d", [RootViewManager instance].viewDescriptionStack.count); //[[RootViewManager instance] setViewControllerForDescription:view]; @@ -667,7 +665,8 @@ static RootViewManager *rootViewManagerInstance = nil; while (viewStack.count > 0 && ![[viewStack lastObject] equal:view]) { [viewStack removeLastObject]; } - return [self _changeCurrentView:view transition:[PhoneMainView getBackwardTransition] animated:ANIMATED addViewToStack:FALSE]; + BOOL addView = (viewStack.count == 0); // if we couldn't find the view in the stack, we need to add it + return [self _changeCurrentView:view transition:[PhoneMainView getBackwardTransition] animated:ANIMATED addViewToStack:addView]; } - (void) setPreviousViewName:(NSString*)previous{