From e2d40f2aa241910c9de6dd0b67c55d24e91cf0a0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 6 Apr 2012 19:08:53 +0200 Subject: [PATCH] stringinput: fix last commit the fix for bounded input fields broke unbounded ones... Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/38f2d7d0ee72de37ac5207693914c821965e9cae Author: Stefan Seyfried Date: 2012-04-06 (Fri, 06 Apr 2012) ------------------ This commit was generated by Migit --- src/gui/widget/stringinput.cpp | 45 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 7ea2a5830..f77a609d6 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -194,12 +194,15 @@ void CStringInput::NormalKeyPressed(const neutrino_msg_t key) value[selected] = validchars[CRCInput::getNumericValue(key)]; int current_value = atoi(value); int tmp = current_value; - if (current_value <= lower_bound) - current_value = lower_bound + 1; - else if (current_value >= upper_bound) - current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ + snprintf(value, size + 1, "%*d", size, current_value); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (selected < (size - 1)) { @@ -292,12 +295,15 @@ void CStringInput::keyUpPressed() int current_value = atoi(value); int tmp = current_value; - if (current_value <= lower_bound) - current_value = lower_bound + 1; - else if (current_value >= upper_bound) - current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ + snprintf(value, size + 1, "%*d", size, current_value); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (tmp != current_value) { @@ -325,12 +331,15 @@ void CStringInput::keyDownPressed() int current_value = atoi(value); int tmp = current_value; - if (current_value <= lower_bound) - current_value = lower_bound + 1; - else if (current_value >= upper_bound) - current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (lower_bound != -1 || upper_bound != -1) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ + snprintf(value, size + 1, "%*d", size, current_value); + } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (tmp != current_value) {