mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 04:46:11 +00:00
Fix formatBytecount's sizes (#1928)
This caused a crash (ref #1925) when seek was set to UT64_MAX.
This commit is contained in:
parent
59af77fb72
commit
64371bb07a
src/common
@ -23,16 +23,18 @@ static QAbstractItemView::ScrollMode scrollMode()
|
||||
|
||||
namespace qhelpers {
|
||||
|
||||
QString formatBytecount(const long bytecount)
|
||||
QString formatBytecount(const uint64_t bytecount)
|
||||
{
|
||||
if (bytecount == 0)
|
||||
if (bytecount == 0) {
|
||||
return "0";
|
||||
const int exp = log(bytecount) / log(1000);
|
||||
}
|
||||
|
||||
const int exp = log(bytecount) / log(1024);
|
||||
constexpr char suffixes[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E'};
|
||||
|
||||
QString str;
|
||||
QTextStream stream(&str);
|
||||
stream << qSetRealNumberPrecision(3) << bytecount / pow(1000, exp)
|
||||
stream << qSetRealNumberPrecision(3) << bytecount / pow(1024, exp)
|
||||
<< ' ' << suffixes[exp] << 'B';
|
||||
return stream.readAll();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class QMenu;
|
||||
class QPaintDevice;
|
||||
|
||||
namespace qhelpers {
|
||||
QString formatBytecount(const long bytecount);
|
||||
QString formatBytecount(const uint64_t bytecount);
|
||||
void adjustColumns(QTreeView *tv, int columnCount, int padding);
|
||||
void adjustColumns(QTreeWidget *tw, int padding);
|
||||
bool selectFirstItem(QAbstractItemView *itemView);
|
||||
|
Loading…
Reference in New Issue
Block a user