* If only a part of the data could be read, the part that couldn't been read

is now cleared - this changes the behaviour of bug #603, but doesn't fix
  it (as this is no DiskProbe bug).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17621 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-05-28 15:27:47 +00:00
parent b0e0bf889d
commit a93fb72be9
2 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@ -939,6 +939,11 @@ DataEditor::Update()
if (bytesRead < B_OK)
return bytesRead;
if ((size_t)bytesRead < fRealViewSize) {
// make sure the rest of data is cleared
memset(fView + bytesRead, 0, fRealViewSize - bytesRead);
}
ApplyChanges();
fNeedsUpdate = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@ -185,7 +185,7 @@ DataView::MessageReceived(BMessage *message)
fOffset = offset;
SetSelection(0, 0);
MakeVisible(0);
}
}
if (message->FindInt32("view_size", &viewSize) == B_OK) {
fDataSize = viewSize;
fData = (uint8 *)realloc(fData, fDataSize);
@ -318,7 +318,7 @@ DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size
}
line += sprintf(line, fBase == kHexBase ? "%0*Lx: " : "%0*Ld: ",
(int)fPositionLength, offset);
(int)fPositionLength, offset);
for (uint32 i = 0; i < kBlockSize; i++) {
if (i >= size) {
@ -359,7 +359,7 @@ DataView::Draw(BRect updateRect)
BPoint location(kHorizontalSpace, kVerticalSpace + fAscent);
for (uint32 i = 0; i < fSizeInView; i += kBlockSize) {
ConvertLine(line, /*fOffset + */i, fData + i, fSizeInView - i);
ConvertLine(line, i, fData + i, fSizeInView - i);
DrawString(line, location);
location.y += fFontHeight;