From 856b7ad6a941099939039e06180c392301596897 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 6 Sep 2010 19:49:48 -0700 Subject: Fixed regression of #295 in the 09.04 experimental --- linden/indra/llui/lllineeditor.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'linden') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 5441d0a..7d91ece 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -2621,28 +2621,37 @@ BOOL LLLineEditor::prevalidateASCII(const LLWString &str) BOOL LLLineEditor::evaluateFloat() { - bool success; - F32 result = 0.f; + bool success = false; std::string expr = getText(); LLStringUtil::toUpper(expr); - success = LLCalc::getInstance()->evalString(expr, result); - - if (!success) + // user deleted the contents, nothing to evaluate -- MC + if (expr.empty()) { - // Move the cursor to near the error on failure - setCursor(LLCalc::getInstance()->getLastErrorPos()); - // *TODO: Translated error message indicating the type of error? Select error text? + return success; } else { - // Replace the expression with the result - std::string result_str = llformat("%f",result); - setText(result_str); - selectAll(); - } + F32 result = 0.f; + success = LLCalc::getInstance()->evalString(expr, result); - return success; + if (!success) + { + // Move the cursor to near the error on failure + setCursor(LLCalc::getInstance()->getLastErrorPos()); + // *TODO: Translated error message indicating the type of error? Select error text? + } + else + { + // Replace the expression with the result + std::ostringstream result_str; + result_str << result; + setText(result_str.str()); + selectAll(); + } + + return success; + } } void LLLineEditor::onMouseCaptureLost() -- cgit v1.1