Skip to content

Commit c3281c4

Browse files
committed
Fix Main Menu Control Bar resolution change/resize glitch via robust state restoration without using early-exit guards
1 parent ff04858 commit c3281c4

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5823,16 +5823,11 @@ void InGameUI::resetIdleWorker()
58235823
void InGameUI::recreateControlBar()
58245824
{
58255825
GameWindow *parent = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
5826-
if (!parent)
5827-
{
5828-
return;
5829-
}
5830-
Bool wasVisible = !parent->winIsHidden();
5826+
Bool wasVisible = (parent && !parent->winIsHidden());
58315827

5832-
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
5833-
if (win)
5828+
if (parent)
58345829
{
5835-
TheWindowManager->winDestroy(win);
5830+
TheWindowManager->winDestroy(parent);
58365831
}
58375832

58385833
m_idleWorkerWin = nullptr;
@@ -5853,6 +5848,10 @@ void InGameUI::recreateControlBar()
58535848
{
58545849
ShowControlBar(TRUE);
58555850
}
5851+
else
5852+
{
5853+
HideControlBar(TRUE);
5854+
}
58565855
}
58575856

58585857
void InGameUI::refreshCustomUiResources()

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5996,16 +5996,11 @@ void InGameUI::resetIdleWorker()
59965996
void InGameUI::recreateControlBar()
59975997
{
59985998
GameWindow *parent = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
5999-
if (!parent)
6000-
{
6001-
return;
6002-
}
6003-
Bool wasVisible = !parent->winIsHidden();
5999+
Bool wasVisible = (parent && !parent->winIsHidden());
60046000

6005-
GameWindow *win = TheWindowManager->winGetWindowFromId(nullptr, TheNameKeyGenerator->nameToKey("ControlBar.wnd:ControlBarParent"));
6006-
if (win)
6001+
if (parent)
60076002
{
6008-
TheWindowManager->winDestroy(win);
6003+
TheWindowManager->winDestroy(parent);
60096004
}
60106005

60116006
m_idleWorkerWin = nullptr;
@@ -6026,6 +6021,10 @@ void InGameUI::recreateControlBar()
60266021
{
60276022
ShowControlBar(TRUE);
60286023
}
6024+
else
6025+
{
6026+
HideControlBar(TRUE);
6027+
}
60296028
}
60306029

60316030
void InGameUI::refreshCustomUiResources()

0 commit comments

Comments
 (0)