@@ -252,7 +252,11 @@ void ControlBar::populatePurchaseScience( Player* player )
252252
253253 setControlCommand ( m_sciencePurchaseWindowsRank3[ i ], commandButton );
254254 ScienceType st = SCIENCE_INVALID;
255- st = commandButton->getScienceVec ()[ 0 ];
255+ ScienceVec sv = commandButton->getScienceVec ();
256+ if (! sv.empty ())
257+ {
258+ st = sv[ 0 ];
259+ }
256260
257261 if ( player->isScienceDisabled ( st ) )
258262 {
@@ -940,6 +944,10 @@ ControlBar::~ControlBar( void )
940944 }
941945
942946 m_radarAttackGlowWindow = NULL ;
947+
948+ if (m_rightHUDCameoWindow && m_rightHUDCameoWindow->winGetUserData ())
949+ delete m_rightHUDCameoWindow->winGetUserData ();
950+
943951} // end ~ControlBar
944952void ControlBarPopupDescriptionUpdateFunc ( WindowLayout *layout, void *param );
945953
@@ -1017,9 +1025,12 @@ void ControlBar::init( void )
10171025 id = TheNameKeyGenerator->nameToKey ( windowName.str () );
10181026 m_commandWindows[ i ] =
10191027 TheWindowManager->winGetWindowFromId ( m_contextParent[ CP_COMMAND ], id );
1020- m_commandWindows[ i ]->winGetPosition (&commandPos.x , &commandPos.y );
1021- m_commandWindows[ i ]->winGetSize (&commandSize.x , &commandSize.y );
1022- m_commandWindows[ i ]->winSetStatus ( WIN_STATUS_USE_OVERLAY_STATES );
1028+ if (m_commandWindows[ i ])
1029+ {
1030+ m_commandWindows[ i ]->winGetPosition (&commandPos.x , &commandPos.y );
1031+ m_commandWindows[ i ]->winGetSize (&commandSize.x , &commandSize.y );
1032+ m_commandWindows[ i ]->winSetStatus ( WIN_STATUS_USE_OVERLAY_STATES );
1033+ }
10231034
10241035 // removed from multiplayer branch
10251036// windowName.format( "ControlBar.wnd:CommandMarker%02d", i + 1 );
@@ -1052,7 +1063,7 @@ void ControlBar::init( void )
10521063 m_sciencePurchaseWindowsRank3[ i ]->winSetStatus ( WIN_STATUS_USE_OVERLAY_STATES );
10531064 } // end for i
10541065
1055- for ( i = 0 ; i < MAX_PURCHASE_SCIENCE_RANK_8; i++ )
1066+ for ( i = 0 ; i < MAX_PURCHASE_SCIENCE_RANK_8; i++ )
10561067 {
10571068 windowName.format ( " GeneralsExpPoints.wnd:ButtonRank8Number%d" , i );
10581069 id = TheNameKeyGenerator->nameToKey ( windowName.str () );
@@ -1933,7 +1944,10 @@ CommandSet* ControlBar::findNonConstCommandSet( const AsciiString& name )
19331944const CommandButton *ControlBar::findCommandButton ( const AsciiString& name )
19341945{
19351946 CommandButton *btn = findNonConstCommandButton (name);
1936- btn = (CommandButton *)btn->friend_getFinalOverride ();
1947+ if ( btn )
1948+ {
1949+ btn = (CommandButton *)btn->friend_getFinalOverride ();
1950+ }
19371951 return btn;
19381952}
19391953
@@ -2059,7 +2073,11 @@ void ControlBar::switchToContext( ControlBarContext context, Drawable *draw )
20592073 // Clear any potentially flashing buttons!
20602074 for ( int i = 0 ; i < MAX_COMMANDS_PER_SET; i++ )
20612075 {
2062- m_commandWindows[ i ]->winClearStatus ( WIN_STATUS_FLASHING );
2076+ // the implementation won't necessarily use the max number of windows possible
2077+ if (m_commandWindows[ i ])
2078+ {
2079+ m_commandWindows[ i ]->winClearStatus ( WIN_STATUS_FLASHING );
2080+ }
20632081 }
20642082 // if there is a current selected drawable then we wil display a selection portrait if present
20652083 if ( draw )
0 commit comments