Skip to content

Commit

Permalink
improve edit limit
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Jan 23, 2024
1 parent 9ae4679 commit 016f5b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2024/01/23
* 完善 event\_from\_name(感谢志鹏提供补丁)
* 修复edit控件输入类型为uint时,最大值设为4294967295导致溢出的问题(感谢雨欣提供补丁)

2024/01/21
* add tk\_pointer\_to\_long/tk\_pointer\_from\_long/tk\_bits\_to\_bytes
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ static bool_t edit_is_valid_value_default(widget_t* widget) {
}
case INPUT_INT:
case INPUT_UINT: {
int32_t v = 0;
int32_t min = (int32_t)(edit->min);
int32_t max = (int32_t)(edit->max);
int64_t v = 0;
int64_t min = (int64_t)(edit->min);
int64_t max = (int64_t)(edit->max);

if (text->size == 0 || text->size > 11) {
return FALSE;
Expand All @@ -414,13 +414,13 @@ static bool_t edit_is_valid_value_default(widget_t* widget) {
return TRUE;
}

wstr_to_int(text, &v);
wstr_to_int64(text, &v);
if (text->size >= 10) {
wstr_t str;
bool_t result = FALSE;

wstr_init(&str, 32);
wstr_from_int(&str, v);
wstr_from_int64(&str, v);
result = wstr_equal(&str, text);
wstr_reset(&str);
if (!result) {
Expand Down

0 comments on commit 016f5b3

Please sign in to comment.