GAL: also scope layer depth push/pops

This means that an early return or an exception between
a manual Push/Pop (or an omission of the Pop) cannot
corrupt the layer stack.

It also means the GAL doesn't have to maintain its own
stack (with the in-scope GAL_SCOPED_ATTRS taking that role).

Reomve the Push/PopDepth functions, as they're only ever
used in pairs, and doing it manually needs more care.
This commit is contained in:
John Beard
2024-11-04 20:41:44 +08:00
parent 3549b77530
commit dbf68a80b8
8 changed files with 48 additions and 58 deletions
+1 -3
View File
@@ -278,11 +278,11 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
highlightColor = drawColor.Brightened( 0.5 ).WithAlpha( 0.8 );
}
KIGFX::GAL_SCOPED_ATTRS scopedAttrs( *gal, KIGFX::GAL_SCOPED_ATTRS::ALL );
gal->SetFillColor( drawColor );
gal->SetStrokeColor( borderColor );
gal->SetIsFill( true );
gal->SetIsStroke( true );
gal->PushDepth();
gal->SetLayerDepth( gal->GetMinDepth() );
double size = aView->ToWorld( EDIT_POINT::POINT_SIZE ) / 2.0;
@@ -328,6 +328,4 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal->DrawLine( line.GetOrigin().GetPosition(), line.GetEnd().GetPosition() );
}
}
gal->PopDepth();
}