From a5dc8f863945135c36c801ecb4a53d116902102f Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Sun, 16 Aug 2009 16:44:31 +0000 Subject: [PATCH] Reverting r30894 as it seems it is what was causing the slowness reported in ticket #4247. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32441 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/InfoWindow.cpp | 65 +++++++++++---------------------- src/kits/tracker/InfoWindow.h | 3 -- 2 files changed, 22 insertions(+), 46 deletions(-) diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index 39e1b372c3..32f2c33dd7 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -55,7 +55,7 @@ All rights reserved. #include #include #include -#include +#include #include #include #include @@ -295,7 +295,7 @@ BInfoWindow::BInfoWindow(Model *model, int32 group_index, LockingList * { SetPulseRate(1000000); // we use pulse to check freebytes on volume - StartWatchingNode(); + TTracker::WatchNode(model->NodeRef(), B_WATCH_ALL | B_WATCH_MOUNT, this); // window list is Locked by Tracker around this constructor if (list) @@ -388,7 +388,10 @@ BInfoWindow::Show() if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) { if (TargetModel()->IsDirectory()) { // if this is a folder then spawn thread to calculate size - StartCalcSizeThread(); + SetSizeStr("calculating" B_UTF8_ELLIPSIS); + fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", + B_NORMAL_PRIORITY, this); + resume_thread(fCalcThreadID); } else { fAttributeView->SetLastSize(TargetModel()->StatBuf()->st_size); @@ -449,7 +452,18 @@ BInfoWindow::MessageReceived(BMessage *message) case kRecalculateSize: { - StartCalcSizeThread(); + fStopCalc = true; + // Wait until any current CalcSize thread has terminated before + // starting a new one + status_t result; + wait_for_thread(fCalcThreadID, &result); + + // Start recalculating.. + fStopCalc = false; + SetSizeStr("calculating" B_UTF8_ELLIPSIS); + fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", + B_NORMAL_PRIORITY, this); + resume_thread(fCalcThreadID); break; } @@ -523,12 +537,12 @@ BInfoWindow::MessageReceived(BMessage *message) AttributeStreamFileNode newNode(TargetModel()->Node()); newNode << memoryNode; + // Start watching this again + TTracker::WatchNode(TargetModel()->NodeRef(), + B_WATCH_ALL | B_WATCH_MOUNT, this); // Tell the attribute view about this new model fAttributeView->ReLinkTargetModel(TargetModel()); - - // Start watching this again - StartWatchingNode(); } break; } @@ -563,14 +577,7 @@ BInfoWindow::MessageReceived(BMessage *message) FSEmptyTrash(); break; - case B_PATH_MONITOR: - - if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) { - if (TargetModel()->IsDirectory()) { - StartCalcSizeThread(); - } - } - + case B_NODE_MONITOR: switch (message->FindInt32("opcode")) { case B_ENTRY_REMOVED: { @@ -688,34 +695,6 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount) } -void -BInfoWindow::StartWatchingNode() -{ - BPath path; - fModel->GetPath(&path); - BPrivate::BPathMonitor::StartWatching(path.Path(), - B_WATCH_ALL | B_WATCH_RECURSIVELY | B_WATCH_MOUNT, this); -} - - -void -BInfoWindow::StartCalcSizeThread() -{ - fStopCalc = true; - // Wait until any current CalcSize thread has terminated before - // starting a new one - status_t result; - wait_for_thread(fCalcThreadID, &result); - - // Start recalculating.. - fStopCalc = false; - SetSizeStr("calculating" B_UTF8_ELLIPSIS); - fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", - B_NORMAL_PRIORITY, this); - resume_thread(fCalcThreadID); -} - - int32 BInfoWindow::CalcSize(void *castToWindow) { diff --git a/src/kits/tracker/InfoWindow.h b/src/kits/tracker/InfoWindow.h index 81f84318da..b5d1df85bb 100644 --- a/src/kits/tracker/InfoWindow.h +++ b/src/kits/tracker/InfoWindow.h @@ -71,9 +71,6 @@ class BInfoWindow : public BWindow { virtual void Show(); private: - void StartWatchingNode(); - void StartCalcSizeThread(); - static BRect InfoWindowRect(bool displayingSymlink); static int32 CalcSize(void *);