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

Commit 5e07c6d

Browse files
author
runrevali
committed
[[ Bug 12071 ]] answer color parameter evaluation too strict
1 parent c4d3c61 commit 5e07c6d

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

docs/notes/bugfix-12071.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# hiliteColor and borderColor is not working in 7.0DP1

engine/src/answer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ void MCAnswer::exec_ctxt(MCExecContext& ctxt)
318318
MCColor t_initial_color;
319319
MCColor *t_initial_color_ptr = &t_initial_color;
320320

321-
if (!ctxt . EvalOptionalExprAsColor(colour . initial, nil, EE_ANSWER_BADQUESTION, t_initial_color_ptr))
322-
return;
321+
// AL-2014-04-01: [[ Bug 12071 ]] If the intial color is empty (i.e. unset), pass nil ptr to dialog.
322+
ctxt . TryToEvalOptionalExprAsColor(colour . initial, nil, EE_ANSWER_BADQUESTION, t_initial_color_ptr);
323323

324324
MCDialogExecAnswerColor(ctxt, t_initial_color_ptr, *t_title, sheet == True);
325325
break;

engine/src/exec.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,25 @@ bool MCExecContext::EvalOptionalExprAsColor(MCExpression *p_expr, MCColor *p_def
12221222
return EvalExprAsColor(p_expr, p_error, *r_value);
12231223
}
12241224

1225+
// AL-2014-04-01: [[ Bug 12071 ]] Need to be able to fail to eval color without throwing an error.
1226+
void MCExecContext::TryToEvalOptionalExprAsColor(MCExpression *p_expr, MCColor *p_default, Exec_errors p_error, MCColor *&r_value)
1227+
{
1228+
if (p_expr == nil)
1229+
{
1230+
r_value = p_default;
1231+
return;
1232+
}
1233+
1234+
// Makes sure the return parameter isn't a nil pointer
1235+
MCAssert(r_value != nil);
1236+
1237+
if (EvalExprAsColor(p_expr, p_error, *r_value))
1238+
return;
1239+
1240+
IgnoreLastError();
1241+
r_value = nil;
1242+
}
1243+
12251244
bool MCExecContext::EvalExprAsRectangle(MCExpression *p_expr, Exec_errors p_error, MCRectangle& r_value)
12261245
{
12271246
MCAssert(p_expr != nil);

engine/src/exec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ class MCExecContext
16781678
bool EvalOptionalExprAsRectangle(MCExpression *expr, MCRectangle *default_value, Exec_errors error, MCRectangle *&r_rectangle);
16791679

16801680
void TryToEvalExprAsArrayRef(MCExpression *p_expr, Exec_errors p_error, MCArrayRef& r_value);
1681+
void TryToEvalOptionalExprAsColor(MCExpression *p_expr, MCColor *p_default, Exec_errors p_error, MCColor *&r_value);
16811682

16821683
private:
16831684
#ifdef LEGACY_EXEC

0 commit comments

Comments
 (0)