From b607d18b7498758e09c3125e97f5231e3a69104c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 26 Feb 2004 04:35:35 +0000 Subject: [PATCH] Now also send a selection update notice if the contents have changed. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6745 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DataView.cpp | 63 +++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index f0b6ad55ae..c47f36eddf 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -103,41 +103,50 @@ DataView::UpdateFromEditor(BMessage *message) if (fData == NULL) return; - if (fEditor.Lock()) { - fFileSize = fEditor.FileSize(); + BAutolock locker(fEditor); - // get the range of the changes + fFileSize = fEditor.FileSize(); - int32 start = 0, end = fDataSize - 1; - off_t offset, size; - if (message != NULL - && message->FindInt64("offset", &offset) == B_OK - && message->FindInt64("size", &size) == B_OK) { - if (offset > fOffset + fDataSize - || offset + size < fOffset) { - // the changes are not within our scope, so we can ignore them - return; - } + // get the range of the changes - if (offset > fOffset) - start = offset - fOffset; - if (offset + size < fOffset + fDataSize) - end = offset + size - fOffset; + int32 start = 0, end = fDataSize - 1; + off_t offset, size; + if (message != NULL + && message->FindInt64("offset", &offset) == B_OK + && message->FindInt64("size", &size) == B_OK) { + if (offset > fOffset + fDataSize + || offset + size < fOffset) { + // the changes are not within our scope, so we can ignore them + return; } - if (fOffset + fDataSize > fFileSize) - fSizeInView = fFileSize - fOffset; - else - fSizeInView = fDataSize; + if (offset > fOffset) + start = offset - fOffset; + if (offset + size < fOffset + fDataSize) + end = offset + size - fOffset; + } - const uint8 *data; - if (fEditor.GetViewBuffer(&data) == B_OK) - // ToDo: copy only the relevant part - memcpy(fData, data, fDataSize); + if (fOffset + fDataSize > fFileSize) + fSizeInView = fFileSize - fOffset; + else + fSizeInView = fDataSize; - fEditor.Unlock(); + const uint8 *data; + if (fEditor.GetViewBuffer(&data) == B_OK) + // ToDo: copy only the relevant part + memcpy(fData, data, fDataSize); - InvalidateRange(start, end); + fEditor.Unlock(); + + InvalidateRange(start, end); + + // we notify our selection listeners also if the + // data in the selection has changed + if (start <= fEnd && end >= fStart) { + BMessage update; + update.AddInt64("start", fStart); + update.AddInt64("end", fEnd); + SendNotices(kDataViewSelection, &update); } }