From: Soeren Apel Date: Mon, 24 Aug 2015 16:21:15 +0000 (+0200) Subject: Fix #595 by correctly handling UINT64_MAX and INT_MAX boundaries X-Git-Tag: pulseview-0.3.0~133 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=765e7d335ab693f587d47b4242e6d72b679d683d;hp=73e170f93ce9deb7bba04966564dcd8af8dfe7e1 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. --- 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);