From 765e7d335ab693f587d47b4242e6d72b679d683d Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Mon, 24 Aug 2015 18:21:15 +0200 Subject: [PATCH] Fix #595 by correctly handling UINT64_MAX and INT_MAX boundaries By using an int64_t to hold UINT64_MAX, it was made to overflow to -1. This lead to range_min=0 and range_max=-1, resulting in a disabled spin button. --- pv/prop/int.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp index 31f518a8..812b7516 100644 --- a/pv/prop/int.cpp +++ b/pv/prop/int.cpp @@ -51,7 +51,8 @@ Int::~Int() QWidget* Int::get_widget(QWidget *parent, bool auto_commit) { - int64_t int_val = 0, range_min = 0, range_max = 0; + int64_t int_val = 0, range_min = 0; + uint64_t range_max = 0; if (spin_box_) return spin_box_; @@ -118,7 +119,7 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit) // custom widget. range_min = max(range_min, (int64_t)INT_MIN); - range_max = min(range_max, (int64_t)INT_MAX); + range_max = min(range_max, (uint64_t)INT_MAX); if (range_) spin_box_->setRange((int)range_->first, (int)range_->second); -- 2.30.2