Skip to content

Commit

Permalink
Fix changing source effect properties doesn't "stick"
Browse files Browse the repository at this point in the history
Fixes #31118
  • Loading branch information
nyalldawson committed Aug 6, 2019
1 parent b96f1ff commit c37ce1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/effects/qgspainteffectregistry.cpp
Expand Up @@ -157,6 +157,12 @@ bool QgsPaintEffectRegistry::isDefaultStack( QgsPaintEffect *effect )
if ( !dynamic_cast< QgsInnerGlowEffect * >( effectStack->effect( 4 ) ) )
return false;

//we don't go as far as to check the individual effect's properties
QgsDrawSourceEffect *sourceEffect = static_cast< QgsDrawSourceEffect * >( effectStack->effect( 2 ) );
if ( !qgsDoubleNear( sourceEffect->opacity(), 1.0 ) )
return false;
if ( sourceEffect->blendMode() != QPainter::CompositionMode_SourceOver )
return false;

//we don't go as far as to check disabled effect's properties
return true;
}
8 changes: 8 additions & 0 deletions tests/src/core/testqgspainteffectregistry.cpp
Expand Up @@ -174,6 +174,14 @@ void TestQgsPaintEffectRegistry::defaultStack()
QgsPaintEffect *effect2 = new DummyPaintEffect();
QVERIFY( !registry->isDefaultStack( effect2 ) );
delete effect2;

effect = static_cast<QgsEffectStack *>( registry->defaultStack() );
static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setOpacity( 0.5 );
QVERIFY( !registry->isDefaultStack( effect ) );
static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setOpacity( 1.0 );
QVERIFY( registry->isDefaultStack( effect ) );
static_cast< QgsDrawSourceEffect * >( effect->effect( 2 ) )->setBlendMode( QPainter::CompositionMode_Lighten );
QVERIFY( !registry->isDefaultStack( effect ) );
}

QGSTEST_MAIN( TestQgsPaintEffectRegistry )
Expand Down

0 comments on commit c37ce1a

Please sign in to comment.