diff --git a/src/apps/diskprobe/DataEditor.cpp b/src/apps/diskprobe/DataEditor.cpp index 07485bf0f2..518d7c0154 100644 --- a/src/apps/diskprobe/DataEditor.cpp +++ b/src/apps/diskprobe/DataEditor.cpp @@ -954,10 +954,46 @@ DataEditor::UpdateIfNeeded(bool *_updated = NULL) status_t DataEditor::ForceUpdate() { + BAutolock locker(this); + status_t status = B_OK; + off_t newSize = fSize; + if (IsAttribute()) { + // update attribute size (we ignore the type for now) + attr_info info; + status = fFile.GetAttrInfo(fAttribute, &info); + if (status != B_OK) { + // The attribute may have just been removed before + // it gets rewritten, so we don't do anything + // else here (we just set the file size to 0) + newSize = 0; + } else + newSize = info.size; + } else if (!IsDevice()) { + // update file size + + if (fFile.GetSize(&newSize) != B_OK) + return B_ERROR; + } + + if (fSize != newSize) { + fSize = newSize; + + // update observers + BMessage update; + update.AddInt64("file_size", newSize); + SendNotices(kMsgDataEditorParameterChange, &update); + } + if (fView == NULL) status = SetViewOffset(fViewOffset); + else { + BMessage update; + update.AddInt64("offset", fViewOffset); + update.AddInt64("size", fViewSize); + SendNotices(kMsgDataEditorUpdate, &update); + } if (status == B_OK) status = Update(); diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index 3016aef6e5..44a0e91777 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -137,8 +137,6 @@ DataView::UpdateFromEditor(BMessage *message) // ToDo: copy only the relevant part memcpy(fData, data, fDataSize); - fEditor.Unlock(); - InvalidateRange(start, end); // we notify our selection listeners also if the @@ -175,6 +173,8 @@ DataView::MessageReceived(BMessage *message) fData = (uint8 *)realloc(fData, fDataSize); UpdateScroller(); } + if (message->FindInt64("file_size", &offset) == B_OK) + UpdateFromEditor(); break; } diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index ced9cf5b51..5b3e117736 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -122,6 +122,8 @@ class HeaderView : public BView, public BInvoker { uint32 BlockSize() const { return fBlockSize; } void SetTo(off_t position, uint32 blockSize); + void UpdateIcon(); + private: void FormatValue(char *buffer, size_t bufferSize, off_t value); void UpdatePositionViews(bool all = true); @@ -593,6 +595,13 @@ HeaderView::GetPreferredSize(float *_width, float *_height) } +void +HeaderView::UpdateIcon() +{ + fIconView->UpdateIcon(); +} + + void HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value) { @@ -1721,14 +1730,32 @@ ProbeView::MessageReceived(BMessage *message) case B_NODE_MONITOR: { switch (message->FindInt32("opcode")) { + case B_STAT_CHANGED: + fEditor.ForceUpdate(); + break; case B_ATTR_CHANGED: { - BMenuBar *bar = Window()->KeyMenuBar(); - if (bar != NULL) { - BMenuItem *item = bar->FindItem("Attributes"); - if (item != NULL && item->Submenu() != NULL) - UpdateAttributesMenu(item->Submenu()); + const char *name; + if (message->FindString("attr", &name) != B_OK) + break; + + if (fEditor.IsAttribute()) { + if (!strcmp(name, fEditor.Attribute())) + fEditor.ForceUpdate(); + } else { + BMenuBar *bar = Window()->KeyMenuBar(); + if (bar != NULL) { + BMenuItem *item = bar->FindItem("Attributes"); + if (item != NULL && item->Submenu() != NULL) + UpdateAttributesMenu(item->Submenu()); + } } + + // There might be a new icon + if (!strcmp(name, "BEOS:TYPE") + || !strcmp(name, "BEOS:M:STD_ICON") + || !strcmp(name, "BEOS:L:STD_ICON")) + fHeaderView->UpdateIcon(); break; } }