From 18497f036dfc7b7bca4caf24332daa54972958e7 Mon Sep 17 00:00:00 2001 From: Janus Date: Mon, 5 Dec 2016 12:09:37 +0100 Subject: [PATCH] DiskUsage: minor clean up * remove unused code. * make fPreviousSnapshot local. * change app_flags to B_SINGLE_LAUNCH when it is invoked by add-on reuses an already scanned volume --- src/apps/diskusage/App.cpp | 13 ++----------- src/apps/diskusage/DiskUsage.cpp | 2 -- src/apps/diskusage/DiskUsage.h | 3 --- src/apps/diskusage/DiskUsage.rdef | 2 +- src/apps/diskusage/MainWindow.cpp | 5 ----- src/apps/diskusage/Scanner.cpp | 9 ++++----- src/apps/diskusage/Scanner.h | 2 -- 7 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/apps/diskusage/App.cpp b/src/apps/diskusage/App.cpp index 4c2c97ef72..7880fda87d 100644 --- a/src/apps/diskusage/App.cpp +++ b/src/apps/diskusage/App.cpp @@ -25,18 +25,9 @@ App::App() : BApplication(kAppSignature), - fMainWindow(NULL), fSavedRefsReceived(NULL) + fMainWindow(NULL), + fSavedRefsReceived(NULL) { - // Get a reference to the help file. - BPath path; - if (find_directory(B_BEOS_DOCUMENTATION_DIRECTORY, &path) == B_OK - && path.Append(kHelpFileName) == B_OK) { - printf("help file =? %s\n", path.Path()); - BEntry entry(path.Path()); - helpFileWasFound = entry.Exists(); - entry.GetRef(&helpFileRef); - } else - helpFileWasFound = false; } diff --git a/src/apps/diskusage/DiskUsage.cpp b/src/apps/diskusage/DiskUsage.cpp index 0088a5e8e9..a1aee9c9c3 100644 --- a/src/apps/diskusage/DiskUsage.cpp +++ b/src/apps/diskusage/DiskUsage.cpp @@ -17,8 +17,6 @@ #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "DiskUsage" -entry_ref helpFileRef; -bool helpFileWasFound = false; int main() diff --git a/src/apps/diskusage/DiskUsage.h b/src/apps/diskusage/DiskUsage.h index 4766cae45f..be9deed9f3 100644 --- a/src/apps/diskusage/DiskUsage.h +++ b/src/apps/diskusage/DiskUsage.h @@ -52,13 +52,10 @@ const float kPieOuterMargin = 10.0; const float kMinSegmentSpan = 2.0; const float kDragThreshold = 5.0; -extern entry_ref helpFileRef; -extern bool helpFileWasFound; #define kMenuSelectVol 'gMSV' #define kBtnRescan 'gBRF' #define kBtnCancel 'gCAN' -#define kBtnHelp 'gHLP' #define kScanRefresh 'gSRF' #define kScanProgress 'gSPR' #define kScanDone 'gSDN' diff --git a/src/apps/diskusage/DiskUsage.rdef b/src/apps/diskusage/DiskUsage.rdef index 514d603156..15bfb082a7 100644 --- a/src/apps/diskusage/DiskUsage.rdef +++ b/src/apps/diskusage/DiskUsage.rdef @@ -14,7 +14,7 @@ resource app_version { long_info = "1.0.2 ©1999 Mike Steed, ©2008-2011 Haiku" }; -resource app_flags B_MULTIPLE_LAUNCH; +resource app_flags B_SINGLE_LAUNCH; resource file_types message { "types" = "application/x-vnd.Be-volume", diff --git a/src/apps/diskusage/MainWindow.cpp b/src/apps/diskusage/MainWindow.cpp index f44f051e76..4f3beb3b60 100644 --- a/src/apps/diskusage/MainWindow.cpp +++ b/src/apps/diskusage/MainWindow.cpp @@ -58,11 +58,6 @@ MainWindow::MessageReceived(BMessage* message) fControlsView->MessageReceived(message); break; - case kBtnHelp: - if (helpFileWasFound) - be_roster->Launch(&helpFileRef); - break; - default: BWindow::MessageReceived(message); break; diff --git a/src/apps/diskusage/Scanner.cpp b/src/apps/diskusage/Scanner.cpp index d98b94bab0..fadbe7bce0 100644 --- a/src/apps/diskusage/Scanner.cpp +++ b/src/apps/diskusage/Scanner.cpp @@ -35,8 +35,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler) fDesiredPath(), fTask(), fBusy(false), - fQuitRequested(false), - fPreviousSnapshot(NULL) + fQuitRequested(false) { Run(); } @@ -144,11 +143,11 @@ Scanner::_DirectoryContains(FileInfo* currentDir, entry_ref* ref) void Scanner::_RunScan(FileInfo* startInfo) { - fPreviousSnapshot = fSnapshot; fQuitRequested = false; BString stringScan(B_TRANSLATE("Scanning %refName%")); if (startInfo == NULL || startInfo == fSnapshot->rootDir) { + VolumeSnapshot* previousSnapshot = fSnapshot; fSnapshot = new VolumeSnapshot(fVolume); stringScan.ReplaceFirst("%refName%", fSnapshot->name.c_str()); fTask = stringScan.String(); @@ -162,7 +161,7 @@ Scanner::_RunScan(FileInfo* startInfo) fSnapshot->rootDir = _GetFileInfo(&root, NULL); if (fSnapshot->rootDir == NULL) { delete fSnapshot; - fSnapshot = fPreviousSnapshot; + fSnapshot = previousSnapshot; fBusy = false; fListener.SendMessage(&fDoneMessage); return; @@ -177,7 +176,7 @@ Scanner::_RunScan(FileInfo* startInfo) fSnapshot->currentDir = NULL; - delete fPreviousSnapshot; + delete previousSnapshot; } else { off_t previousVolumeCapacity = fSnapshot->capacity; off_t previousVolumeFreeBytes = fSnapshot->freeBytes; diff --git a/src/apps/diskusage/Scanner.h b/src/apps/diskusage/Scanner.h index db0cd7a395..eabf1b7612 100644 --- a/src/apps/diskusage/Scanner.h +++ b/src/apps/diskusage/Scanner.h @@ -72,8 +72,6 @@ private: string fTask; bool fBusy; bool fQuitRequested; - - VolumeSnapshot* fPreviousSnapshot; }; #endif // SCANNER_H