More GDI conservation

This commit is contained in:
Seth Hillbrand 2025-08-26 06:04:30 -07:00
parent 4660c72c69
commit dad60f99c0
2 changed files with 11 additions and 0 deletions

View File

@ -66,9 +66,18 @@ ACTION_MENU::~ACTION_MENU()
Disconnect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), nullptr, this );
Disconnect( wxEVT_IDLE, wxIdleEventHandler( ACTION_MENU::OnIdle ), nullptr, this );
// Explicitly release the GDI resources
for( auto subitem : GetMenuItems() )
subitem->SetBitmap( wxNullBitmap );
// Set parent to NULL to prevent submenus from unregistering from a nonexistent object
for( ACTION_MENU* menu : m_submenus )
{
for( auto menuItem : GetMenuItems() )
menuItem->SetBitmap( wxNullBitmap );
menu->SetParent( nullptr );
}
ACTION_MENU* parent = dynamic_cast<ACTION_MENU*>( GetParent() );
@ -108,6 +117,7 @@ void ACTION_MENU::DisplayTitle( bool aDisplay )
// Destroy the menu entry keeping the title..
wxMenuItem* item = FindItemByPosition( 0 );
wxASSERT( item->GetItemLabelText() == GetTitle() );
item->SetBitmap( wxNullBitmap );
Destroy( item );
// ..and separator

View File

@ -57,6 +57,7 @@ void LAYER_PRESENTATION::DrawColorSwatch( wxBitmap& aLayerbmp, const COLOR4D& aB
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SelectObject( wxNullBitmap );
}