Tracker: NodePreloader style fixes
This commit is contained in:
@@ -59,17 +59,20 @@ NodePreloader::InstallNodePreloader(const char* name, BLooper* host)
|
|||||||
AutoLock<BLooper> lock(host);
|
AutoLock<BLooper> lock(host);
|
||||||
if (!lock)
|
if (!lock)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
host->AddHandler(result);
|
host->AddHandler(result);
|
||||||
}
|
}
|
||||||
result->Run();
|
result->Run();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NodePreloader::NodePreloader(const char* name)
|
NodePreloader::NodePreloader(const char* name)
|
||||||
: BHandler(name),
|
:
|
||||||
fModelList(20, true),
|
BHandler(name),
|
||||||
fQuitRequested(false)
|
fModelList(20, true),
|
||||||
|
fQuitRequested(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +101,7 @@ NodePreloader::FindModel(node_ref itemNode) const
|
|||||||
if (*model->NodeRef() == itemNode)
|
if (*model->NodeRef() == itemNode)
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +122,9 @@ NodePreloader::MessageReceived(BMessage* message)
|
|||||||
message->FindInt32("device", &itemNode.device);
|
message->FindInt32("device", &itemNode.device);
|
||||||
message->FindInt64("node", &itemNode.node);
|
message->FindInt64("node", &itemNode.node);
|
||||||
Model* model = FindModel(itemNode);
|
Model* model = FindModel(itemNode);
|
||||||
if (!model)
|
if (model == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//PRINT(("preloader removing file %s\n", model->Name()));
|
//PRINT(("preloader removing file %s\n", model->Name()));
|
||||||
IconCache::sIconCache->Removing(model);
|
IconCache::sIconCache->Removing(model);
|
||||||
fModelList.RemoveItem(model);
|
fModelList.RemoveItem(model);
|
||||||
@@ -136,8 +141,9 @@ NodePreloader::MessageReceived(BMessage* message)
|
|||||||
const char* attrName;
|
const char* attrName;
|
||||||
message->FindString("attr", &attrName);
|
message->FindString("attr", &attrName);
|
||||||
Model* model = FindModel(itemNode);
|
Model* model = FindModel(itemNode);
|
||||||
if (!model)
|
if (model == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BModelOpener opener(model);
|
BModelOpener opener(model);
|
||||||
IconCache::sIconCache->IconChanged(model->ResolveIfLink());
|
IconCache::sIconCache->IconChanged(model->ResolveIfLink());
|
||||||
//PRINT(("preloader updating file %s\n", model->Name()));
|
//PRINT(("preloader updating file %s\n", model->Name()));
|
||||||
@@ -181,9 +187,10 @@ NodePreloader::PreloadOne(const char* dirPath)
|
|||||||
|
|
||||||
Model* model = new Model(&ref, true);
|
Model* model = new Model(&ref, true);
|
||||||
if (model->InitCheck() == B_OK && model->IconFrom() == kUnknownSource) {
|
if (model->InitCheck() == B_OK && model->IconFrom() == kUnknownSource) {
|
||||||
TTracker::WatchNode(model->NodeRef(), B_WATCH_STAT
|
TTracker::WatchNode(model->NodeRef(),
|
||||||
| B_WATCH_ATTR, this);
|
B_WATCH_STAT | B_WATCH_ATTR, this);
|
||||||
IconCache::sIconCache->Preload(model, kNormalIcon, B_MINI_ICON, true);
|
IconCache::sIconCache->Preload(model, kNormalIcon, B_MINI_ICON,
|
||||||
|
true);
|
||||||
fModelList.AddItem(model);
|
fModelList.AddItem(model);
|
||||||
model->CloseNode();
|
model->CloseNode();
|
||||||
} else
|
} else
|
||||||
@@ -196,7 +203,8 @@ void
|
|||||||
NodePreloader::Preload()
|
NodePreloader::Preload()
|
||||||
{
|
{
|
||||||
for (int32 count = 100; count >= 0; count--) {
|
for (int32 count = 100; count >= 0; count--) {
|
||||||
// wait for a little bit before going ahead to reduce disk access contention
|
// wait for a little bit before going ahead to reduce disk access
|
||||||
|
// contention
|
||||||
snooze(100000);
|
snooze(100000);
|
||||||
if (fQuitRequested) {
|
if (fQuitRequested) {
|
||||||
fLock.Unlock();
|
fLock.Unlock();
|
||||||
@@ -214,6 +222,7 @@ NodePreloader::Preload()
|
|||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_BEOS_APPS_DIRECTORY, &path) == B_OK)
|
if (find_directory(B_BEOS_APPS_DIRECTORY, &path) == B_OK)
|
||||||
PreloadOne(path.Path());
|
PreloadOne(path.Path());
|
||||||
|
|
||||||
if (find_directory(B_BEOS_PREFERENCES_DIRECTORY, &path) == B_OK)
|
if (find_directory(B_BEOS_PREFERENCES_DIRECTORY, &path) == B_OK)
|
||||||
PreloadOne(path.Path());
|
PreloadOne(path.Path());
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ All rights reserved.
|
|||||||
// aliasing after a deletion, etc.
|
// aliasing after a deletion, etc.
|
||||||
//
|
//
|
||||||
// The node preloader knows which icons to preload
|
// The node preloader knows which icons to preload
|
||||||
#ifndef __NODE_CACHE_PRELOADER__
|
#ifndef _NODE_CACHE_PRELOADER_H
|
||||||
#define __NODE_CACHE_PRELOADER__
|
#define _NODE_CACHE_PRELOADER_H
|
||||||
|
|
||||||
|
|
||||||
#include <Handler.h>
|
#include <Handler.h>
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
#include "ObjectList.h"
|
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -82,4 +82,5 @@ private:
|
|||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
#endif // __NODE_CACHE_PRELOADER__
|
|
||||||
|
#endif // _NODE_CACHE_PRELOADER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user