From a93fb72be9510667dacf7c433859d246edacda55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 28 May 2006 15:27:47 +0000 Subject: [PATCH] * 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 --- src/apps/diskprobe/DataEditor.cpp | 7 ++++++- src/apps/diskprobe/DataView.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 9737c6f62a..20194af99f 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -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; diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index 72450cf5c7..0a43bb2b74 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -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;