[haiku-commits] haiku: hrev50725 - src/apps/diskusage

  • From: "" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "janus2" for DMARC)
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 2 Dec 2016 19:41:00 +0100 (CET)

hrev50725 adds 1 changeset to branch 'master'
old head: d0608011469b73573181392b49a3d9971c68538e
new head: 1fad3c98b681102e69588cd3998c9c5b1d026187
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=1fad3c98b681+%5Ed0608011469b

----------------------------------------------------------------------------

1fad3c98b681: DiskUsage: avoid different crashes on rescan
  
  * Fixes #9380, #11442.

                                                [ Janus <janus2@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50725
Commit:      1fad3c98b681102e69588cd3998c9c5b1d026187
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1fad3c98b681
Author:      Janus <janus2@xxxxxxxxx>
Date:        Fri Dec  2 17:45:35 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/9380
Ticket:      https://dev.haiku-os.org/ticket/11442

----------------------------------------------------------------------------

2 files changed, 13 insertions(+), 5 deletions(-)
src/apps/diskusage/PieView.cpp |  1 +
src/apps/diskusage/Scanner.cpp | 17 ++++++++++++-----

----------------------------------------------------------------------------

diff --git a/src/apps/diskusage/PieView.cpp b/src/apps/diskusage/PieView.cpp
index 3186626..cdb4942 100644
--- a/src/apps/diskusage/PieView.cpp
+++ b/src/apps/diskusage/PieView.cpp
@@ -725,6 +725,7 @@ PieView::_ShowContextMenu(FileInfo* info, BPoint p)
                                        break;
                                case kIdxRescan:
                                        fScanner->Refresh(info);
+                                       fWindow->EnableCancel();
                                        Invalidate();
                                        break;
                                default: // must be "Open With" submenu
diff --git a/src/apps/diskusage/Scanner.cpp b/src/apps/diskusage/Scanner.cpp
index ac551c9..d98b94b 100644
--- a/src/apps/diskusage/Scanner.cpp
+++ b/src/apps/diskusage/Scanner.cpp
@@ -177,7 +177,10 @@ Scanner::_RunScan(FileInfo* startInfo)
 
                fSnapshot->currentDir = NULL;
 
+               delete fPreviousSnapshot;
        } else {
+               off_t previousVolumeCapacity = fSnapshot->capacity;
+               off_t previousVolumeFreeBytes = fSnapshot->freeBytes;
                fSnapshot->capacity = fVolume->Capacity();
                fSnapshot->freeBytes = fVolume->FreeBytes();
                stringScan.ReplaceFirst("%refName%", startInfo->ref.name);
@@ -193,8 +196,8 @@ Scanner::_RunScan(FileInfo* startInfo)
                        vector<FileInfo *>::iterator i = 
parent->children.begin();
                        FileInfo* newInfo = _GetFileInfo(&startDir, parent);
                        if (newInfo == NULL) {
-                               delete fSnapshot;
-                               fSnapshot = fPreviousSnapshot;
+                               fSnapshot->capacity = previousVolumeCapacity;
+                               fSnapshot->freeBytes = previousVolumeFreeBytes;
                                fBusy = false;
                                fListener.SendMessage(&fDoneMessage);
                                return;                         
@@ -206,13 +209,17 @@ Scanner::_RunScan(FileInfo* startInfo)
                        parent->children[idx] = newInfo;
 
                        // Fixup count and size fields in parent directory.
-                       parent->size += newInfo->size - startInfo->size;
-                       parent->count += newInfo->count - startInfo->count;
+                       off_t sizeDiff = newInfo->size - startInfo->size;
+                       off_t countDiff = newInfo->count - startInfo->count;
+                       while (parent != NULL) {
+                               parent->size += sizeDiff;
+                               parent->count += countDiff;
+                               parent = parent->parent;
+                       }
 
                        delete startInfo;
                }
        }
-       delete fPreviousSnapshot;
        fBusy = false;
        _ChangeToDesired();
        fListener.SendMessage(&fDoneMessage);


Other related posts:

  • » [haiku-commits] haiku: hrev50725 - src/apps/diskusage