mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 12:56: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
@ -23,16 +23,18 @@ static QAbstractItemView::ScrollMode scrollMode()
|
|||||||
|
|
||||||
namespace qhelpers {
|
namespace qhelpers {
|
||||||
|
|
||||||
QString formatBytecount(const long bytecount)
|
QString formatBytecount(const uint64_t bytecount)
|
||||||
{
|
{
|
||||||
if (bytecount == 0)
|
if (bytecount == 0) {
|
||||||
return "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'};
|
constexpr char suffixes[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E'};
|
||||||
|
|
||||||
QString str;
|
QString str;
|
||||||
QTextStream stream(&str);
|
QTextStream stream(&str);
|
||||||
stream << qSetRealNumberPrecision(3) << bytecount / pow(1000, exp)
|
stream << qSetRealNumberPrecision(3) << bytecount / pow(1024, exp)
|
||||||
<< ' ' << suffixes[exp] << 'B';
|
<< ' ' << suffixes[exp] << 'B';
|
||||||
return stream.readAll();
|
return stream.readAll();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class QMenu;
|
|||||||
class QPaintDevice;
|
class QPaintDevice;
|
||||||
|
|
||||||
namespace qhelpers {
|
namespace qhelpers {
|
||||||
QString formatBytecount(const long bytecount);
|
QString formatBytecount(const uint64_t bytecount);
|
||||||
void adjustColumns(QTreeView *tv, int columnCount, int padding);
|
void adjustColumns(QTreeView *tv, int columnCount, int padding);
|
||||||
void adjustColumns(QTreeWidget *tw, int padding);
|
void adjustColumns(QTreeWidget *tw, int padding);
|
||||||
bool selectFirstItem(QAbstractItemView *itemView);
|
bool selectFirstItem(QAbstractItemView *itemView);
|
||||||
|
Loading…
Reference in New Issue
Block a user