Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ friend class GameWindow;
protected:

void processDestroyList(); ///< process windows waiting to be killed
void removeWindowFromModalStack( GameWindow *window );

Int drawWindow( GameWindow *window ); ///< draw this window

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ void GameWindowManager::processDestroyList()
if( m_keyboardFocus == doDestroy )
winSetFocus( nullptr );

if( (m_modalHead != nullptr) && (doDestroy == m_modalHead->window) )
winUnsetModal( m_modalHead->window );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed?


if( m_currMouseRgn == doDestroy )
m_currMouseRgn = nullptr;

Expand Down Expand Up @@ -1422,8 +1419,7 @@ Int GameWindowManager::winDestroy( GameWindow *window )
if( m_keyboardFocus == window )
winSetFocus( nullptr );

if( (m_modalHead != nullptr) && (window == m_modalHead->window) )
winUnsetModal( m_modalHead->window );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to fix winUnsetModal() so that it will remove a window from the modal stack regardless of location in the stack.

Then the code can just become

	if( (m_modalHead != nullptr)
		winUnsetModal( window );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is correct to remove it from the head only for some of the callers?

Maybe we can have 2 functions:

winUnsetModalAtHead
winUnsetModalAnywhere

Or if we just need winUnsetModalAnywhere, then replace the current winUnsetModal.

removeWindowFromModalStack( window );

if( m_currMouseRgn == window )
m_currMouseRgn = nullptr;
Expand Down Expand Up @@ -1555,6 +1551,26 @@ Int GameWindowManager::winUnsetModal( GameWindow *window )

}

// TheSuperHackers @bugfix arcticdolphin 27/08/2026 Remove destroyed windows from the entire modal stack.
void GameWindowManager::removeWindowFromModalStack( GameWindow *window )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just preference but this is maybe more readable:

void GameWindowManager::removeWindowFromModalStack( GameWindow *window )
  {
  	ModalWindow *previous = nullptr;
  	ModalWindow *modal = m_modalHead;

  	while( modal )
  	{
  		ModalWindow *next = modal->next;

  		if( modal->window == window )
  		{
  			if( previous )
  				previous->next = next;
  			else
  				m_modalHead = next;

  			deleteInstance(modal);
  		}
  		else
  		{
  			previous = modal;
  		}

  		modal = next;
  	}
  }

{
ModalWindow **link = &m_modalHead;

while( *link )
{
ModalWindow *modal = *link;

if( modal->window != window )
{
link = &modal->next;
continue;
}

*link = modal->next;
deleteInstance(modal);
}
}

//-------------------------------------------------------------------------------------------------
/** Get the grabbed window */
//-------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ friend class GameWindow;
protected:

void processDestroyList(); ///< process windows waiting to be killed
void removeWindowFromModalStack( GameWindow *window );

Int drawWindow( GameWindow *window ); ///< draw this window

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ void GameWindowManager::processDestroyList()
if( m_keyboardFocus == doDestroy )
winSetFocus( nullptr );

if( (m_modalHead != nullptr) && (doDestroy == m_modalHead->window) )
winUnsetModal( m_modalHead->window );

if( m_currMouseRgn == doDestroy )
m_currMouseRgn = nullptr;

Expand Down Expand Up @@ -1422,8 +1419,7 @@ Int GameWindowManager::winDestroy( GameWindow *window )
if( m_keyboardFocus == window )
winSetFocus( nullptr );

if( (m_modalHead != nullptr) && (window == m_modalHead->window) )
winUnsetModal( m_modalHead->window );
removeWindowFromModalStack( window );

if( m_currMouseRgn == window )
m_currMouseRgn = nullptr;
Expand Down Expand Up @@ -1555,6 +1551,26 @@ Int GameWindowManager::winUnsetModal( GameWindow *window )

}

// TheSuperHackers @bugfix arcticdolphin 27/08/2026 Remove destroyed windows from the entire modal stack.
void GameWindowManager::removeWindowFromModalStack( GameWindow *window )
{
ModalWindow **link = &m_modalHead;

while( *link )
{
ModalWindow *modal = *link;

if( modal->window != window )
{
link = &modal->next;
continue;
}

*link = modal->next;
deleteInstance(modal);
}
}

//-------------------------------------------------------------------------------------------------
/** Get the grabbed window */
//-------------------------------------------------------------------------------------------------
Expand Down
Loading