Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 710c259

Browse files
peter-blivecodeali
authored andcommitted
Tidy bitmap effect setters/getters to prevent maybe-uninitialized
Move the bitmap effect property lookup into the block where it is actually used. This is both cleaner and prevents `-Wmaybe-uninitialized` warnings.
1 parent 057f3b5 commit 710c259

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

engine/src/bitmapeffect.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,6 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
678678
t_effect = &self -> effects[t_type];
679679
else
680680
t_effect = nil;
681-
682-
MCBitmapEffectProperty t_prop;
683-
if (!MCNameIsEmpty(p_index) && MCBitmapEffectLookupProperty(t_type, p_index, t_prop) != ES_NORMAL)
684-
return false;
685681

686682
if (t_is_array)
687683
{
@@ -716,6 +712,10 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
716712
}
717713
else
718714
{
715+
MCBitmapEffectProperty t_prop;
716+
if (MCBitmapEffectLookupProperty(t_type, p_index,
717+
t_prop) != ES_NORMAL)
718+
return false;
719719
MCBitmapEffectFetchProperty(ctxt, t_effect, t_prop, r_value);
720720
return true;
721721
}
@@ -983,7 +983,6 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
983983
return true;
984984
}
985985

986-
MCBitmapEffectProperty t_prop;
987986
MCBitmapEffect effect;
988987
bool t_dirty;
989988

@@ -1003,10 +1002,6 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
10031002
t_dirty = true;
10041003
}
10051004

1006-
// Lookup the property and ensure it is appropriate for our type.
1007-
if (!MCNameIsEmpty(p_index) && MCBitmapEffectLookupProperty(t_type, p_index, t_prop) != ES_NORMAL)
1008-
return false;
1009-
10101005
if (t_is_array)
10111006
{
10121007
bool t_dirty_array;
@@ -1037,8 +1032,15 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
10371032

10381033
}
10391034
else
1035+
{
1036+
MCBitmapEffectProperty t_prop;
1037+
if (MCBitmapEffectLookupProperty(t_type, p_index,
1038+
t_prop) != ES_NORMAL)
1039+
return false;
1040+
10401041
MCBitmapEffectStoreProperty(ctxt, effect, t_prop, p_value, t_dirty);
1041-
1042+
}
1043+
10421044
if (t_dirty)
10431045
{
10441046
// If we are currently empty, then allocate a new object

0 commit comments

Comments
 (0)