Patch by Bryce Groff with small style changes by myself: Scale the values for
the partition size slider to MBs, so that the int32 doesn't overflow for larger partitions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31249 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -78,6 +78,11 @@ CreateParamsPanel::CreateParamsPanel(BWindow* window, off_t offset, off_t size)
|
||||
fReturnValue(GO_CANCELED)
|
||||
{
|
||||
AddCommonFilter(fEscapeFilter);
|
||||
|
||||
// Scale offset, and size from bytes to megabytes (2^20)
|
||||
// so that we do not run over a signed int32.
|
||||
offset /= kMegaByte;
|
||||
size /= kMegaByte;
|
||||
_CreateViewControls(offset, size);
|
||||
}
|
||||
|
||||
@@ -156,7 +161,8 @@ CreateParamsPanel::Go(off_t& offset, off_t& size, BString& type)
|
||||
_type = "BFS Filesystem";
|
||||
type << _type;
|
||||
}
|
||||
size = fSizeSlider->Value();
|
||||
// Return the value back as bytes.
|
||||
size = (off_t)fSizeSlider->Value() * kMegaByte;
|
||||
}
|
||||
|
||||
int32 value = fReturnValue;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Erik Jaesler <[email protected]>
|
||||
* Ithamar R. Adema <[email protected]>
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* Bryce Groff <[email protected]>
|
||||
*/
|
||||
|
||||
#include "Support.h"
|
||||
@@ -16,9 +17,6 @@
|
||||
#include <String.h>
|
||||
|
||||
|
||||
uint32 kMegaByte = 1048576;
|
||||
|
||||
|
||||
const char*
|
||||
string_for_size(off_t size, char *string)
|
||||
{
|
||||
@@ -124,8 +122,10 @@ SizeSlider::SizeSlider(const char* name, const char* label,
|
||||
{
|
||||
SetBarColor((rgb_color){ 0, 80, 255, 255 });
|
||||
BString offset, size;
|
||||
offset << fOffset / kMegaByte; offset << " MB";
|
||||
size << fSize / kMegaByte; size << " MB";
|
||||
offset << fOffset;
|
||||
offset << " MB";
|
||||
size << fSize;
|
||||
size << " MB";
|
||||
SetLimitLabels(offset.String(), size.String());
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ const char*
|
||||
SizeSlider::UpdateText() const
|
||||
{
|
||||
fStatusLabel.Truncate(0);
|
||||
fStatusLabel << (Value() / kMegaByte);
|
||||
fStatusLabel << Value();
|
||||
fStatusLabel << " MB";
|
||||
|
||||
return fStatusLabel.String();
|
||||
|
||||
@@ -27,6 +27,9 @@ enum {
|
||||
GO_SUCCESS
|
||||
};
|
||||
|
||||
|
||||
static const uint32 kMegaByte = 1048576;
|
||||
|
||||
class SpaceIDMap : public HashMap<HashString, partition_id> {
|
||||
public:
|
||||
SpaceIDMap();
|
||||
|
||||
Reference in New Issue
Block a user