Skip to content

Commit a827573

Browse files
committed
Fix a crash when unsupported graphic effects are used
1 parent ed77162 commit a827573

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/scratch/target.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ bool Target::touchingColor(const Value &color, const Value &mask) const
540540
/*! Returns the value of the given graphics effect. */
541541
double Target::graphicsEffectValue(IGraphicsEffect *effect) const
542542
{
543+
if (!effect)
544+
return 0;
545+
543546
auto it = impl->graphicsEffects.find(effect);
544547

545548
if (it == impl->graphicsEffects.cend())
@@ -551,8 +554,8 @@ double Target::graphicsEffectValue(IGraphicsEffect *effect) const
551554
/*! Sets the value of the given graphics effect. */
552555
void Target::setGraphicsEffectValue(IGraphicsEffect *effect, double value)
553556
{
554-
assert(effect);
555-
impl->graphicsEffects[effect] = effect->clamp(value);
557+
if (effect)
558+
impl->graphicsEffects[effect] = effect->clamp(value);
556559
}
557560

558561
/*! Sets the value of all graphics effects to 0 (clears them). */

0 commit comments

Comments
 (0)