Fixed memory leak caused by ViewUpdate() with VIEW_ITEM::GEOMETRY/LAYER parameters.

This commit is contained in:
Maciej Suminski 2013-10-02 13:57:21 +02:00
parent ff3c2bb66b
commit 54946f46f7
3 changed files with 9 additions and 7 deletions

View File

@ -676,9 +676,9 @@ struct VIEW::unlinkItem
}; };
struct VIEW::recacheLayer struct VIEW::recacheItem
{ {
recacheLayer( VIEW* aView, GAL* aGal, int aLayer, bool aImmediately ) : recacheItem( VIEW* aView, GAL* aGal, int aLayer, bool aImmediately ) :
view( aView ), gal( aGal ), layer( aLayer ), immediately( aImmediately ) view( aView ), gal( aGal ), layer( aLayer ), immediately( aImmediately )
{ {
} }
@ -688,9 +688,7 @@ struct VIEW::recacheLayer
// Remove previously cached group // Remove previously cached group
int prevGroup = aItem->getGroup( layer ); int prevGroup = aItem->getGroup( layer );
if( prevGroup >= 0 ) if( prevGroup >= 0 )
{
gal->DeleteGroup( prevGroup ); gal->DeleteGroup( prevGroup );
}
if( immediately ) if( immediately )
{ {
@ -882,6 +880,10 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
m_gal->SetLayerDepth( l.renderingOrder ); m_gal->SetLayerDepth( l.renderingOrder );
// Redraw the item from scratch // Redraw the item from scratch
int prevGroup = aItem->getGroup( aLayer );
if( prevGroup >= 0 )
m_gal->DeleteGroup( prevGroup );
int group = m_gal->BeginGroup(); int group = m_gal->BeginGroup();
aItem->setGroup( aLayer, group ); aItem->setGroup( aLayer, group );
m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ); m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer );
@ -966,7 +968,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
{ {
m_gal->SetTarget( l->target ); m_gal->SetTarget( l->target );
m_gal->SetLayerDepth( l->renderingOrder ); m_gal->SetLayerDepth( l->renderingOrder );
recacheLayer visitor( this, m_gal, l->id, aImmediately ); recacheItem visitor( this, m_gal, l->id, aImmediately );
l->items->Query( r, visitor ); l->items->Query( r, visitor );
MarkTargetDirty( l->target ); MarkTargetDirty( l->target );
} }

View File

@ -500,7 +500,7 @@ private:
// Function objects that need to access VIEW/VIEW_ITEM private/protected members // Function objects that need to access VIEW/VIEW_ITEM private/protected members
struct clearLayerCache; struct clearLayerCache;
struct recacheLayer; struct recacheItem;
struct drawItem; struct drawItem;
struct unlinkItem; struct unlinkItem;
struct updateItemsColor; struct updateItemsColor;

View File

@ -78,7 +78,7 @@ bool MOVE_TOOL::Init()
int MOVE_TOOL::Main( TOOL_EVENT& aEvent ) int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
{ {
const SELECTION_TOOL::SELECTION selection = m_selectionTool->GetSelection(); const SELECTION_TOOL::SELECTION& selection = m_selectionTool->GetSelection();
if( selection.Empty() ) if( selection.Empty() )
return 0; // there are no items to operate on return 0; // there are no items to operate on