Numeric input controls where the input box has a spinner assigned, accept out of range values

Bug #2143720 reported by eMTee
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DC++
Fix Committed
Medium
Unassigned

Bug Description

Transfer speed limits and many other UI input controls for various settings, where the input box has a spinner assigned, accepts overy large values to be typed in, even outside their specified valid range.
This can cause various severe problems when the user unintentionally enters invalid values into these boxes, like integer overflows in settings that not expected to be negative, etc.. - these issues can evidently prevent entering into hubs, they can cause permanent bans or possibly other anomalies.

Initially reported as an issue with the Custom value setting input for transfer limits (accessible from the MainWindow statusbar), but later it turned out this is an issue with all input boxes with assigned spinners.

The existing code everywhere expects the Spinners to do a valid value range check and the assumption that it'd work fine probably came from the dwt API docs, specifically from a comment starts in https://sourceforge.net/p/dcplusplus/code/ci/default/tree/dwt/include/dwt/widgets/Spinner.h#l98

This info is just partially true - win32 spinners do the range check for their own spinner button events only, they don't provide valid input range check for numbers typed into their buddy controls until one of the spin buttons are clicked. The current dwt spinner wrapper does not implement the functionality, either, or if had before then maybe it's been lost somewhere during its evolution from SmartWin.

A simple fix with a minimal change has been committed that does the sync with the spinner when the content of the buddy control changes. While this introduces a slightly frustrating UX as it on-the-fly clamps out of range values typed into the buddy, otherwise it works fine and prevents any type of out-of-range situations.

Possible other solutions may utilize the EN_KILLFOCUS event, that check and correct the buddy value only when the control loses focus and so provide a better UX but that needs a bit more complex implememntation as e.g. closing windows with the Enter key won't move the focus etc...

eMTee (realprogger)
summary: Numeric input controls where the input box has a spinner assigned,
- accept overy large values
+ accept out of range values
eMTee (realprogger)
description: updated
eMTee (realprogger)
Changed in dcplusplus:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.