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
This commit is contained in:
Philippe Saint-Pierre
2009-08-16 16:44:31 +00:00
parent da2b227ec7
commit a5dc8f8639
2 changed files with 22 additions and 46 deletions
+22 -43
View File
@@ -55,7 +55,7 @@ All rights reserved.
#include <MenuField.h> #include <MenuField.h>
#include <Mime.h> #include <Mime.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <PathMonitor.h> #include <NodeMonitor.h>
#include <Path.h> #include <Path.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <Region.h> #include <Region.h>
@@ -295,7 +295,7 @@ BInfoWindow::BInfoWindow(Model *model, int32 group_index, LockingList<BWindow> *
{ {
SetPulseRate(1000000); // we use pulse to check freebytes on volume 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 // window list is Locked by Tracker around this constructor
if (list) if (list)
@@ -388,7 +388,10 @@ BInfoWindow::Show()
if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) { if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) {
if (TargetModel()->IsDirectory()) { if (TargetModel()->IsDirectory()) {
// if this is a folder then spawn thread to calculate size // 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 { } else {
fAttributeView->SetLastSize(TargetModel()->StatBuf()->st_size); fAttributeView->SetLastSize(TargetModel()->StatBuf()->st_size);
@@ -449,7 +452,18 @@ BInfoWindow::MessageReceived(BMessage *message)
case kRecalculateSize: 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; break;
} }
@@ -523,12 +537,12 @@ BInfoWindow::MessageReceived(BMessage *message)
AttributeStreamFileNode newNode(TargetModel()->Node()); AttributeStreamFileNode newNode(TargetModel()->Node());
newNode << memoryNode; 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 // Tell the attribute view about this new model
fAttributeView->ReLinkTargetModel(TargetModel()); fAttributeView->ReLinkTargetModel(TargetModel());
// Start watching this again
StartWatchingNode();
} }
break; break;
} }
@@ -563,14 +577,7 @@ BInfoWindow::MessageReceived(BMessage *message)
FSEmptyTrash(); FSEmptyTrash();
break; break;
case B_PATH_MONITOR: case B_NODE_MONITOR:
if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) {
if (TargetModel()->IsDirectory()) {
StartCalcSizeThread();
}
}
switch (message->FindInt32("opcode")) { switch (message->FindInt32("opcode")) {
case B_ENTRY_REMOVED: 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 int32
BInfoWindow::CalcSize(void *castToWindow) BInfoWindow::CalcSize(void *castToWindow)
{ {
-3
View File
@@ -71,9 +71,6 @@ class BInfoWindow : public BWindow {
virtual void Show(); virtual void Show();
private: private:
void StartWatchingNode();
void StartCalcSizeThread();
static BRect InfoWindowRect(bool displayingSymlink); static BRect InfoWindowRect(bool displayingSymlink);
static int32 CalcSize(void *); static int32 CalcSize(void *);