Tracker: A few more style fixes to Utilities
* icon_size size => icon_size which (I've settled on which)
* fOrigBitmap => fOriginalBitmap
* resizeMask/resizeFlags => resizingMode (header and cpp match)
* error => result
* explicit NULL checks for pointers
* multi-line conditional ifs get {}'s
* rename result to more descriptive name when not status_t
This commit is contained in:
@@ -99,15 +99,15 @@ uint32
|
|||||||
HashString(const char* string, uint32 seed)
|
HashString(const char* string, uint32 seed)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
uint32 result = seed;
|
uint32 hash = seed;
|
||||||
|
|
||||||
while((ch = *string++) != 0) {
|
while((ch = *string++) != 0) {
|
||||||
result = (result << 7) ^ (result >> 24);
|
hash = (hash << 7) ^ (hash >> 24);
|
||||||
result ^= ch;
|
hash ^= ch;
|
||||||
}
|
}
|
||||||
|
hash ^= hash << 12;
|
||||||
|
|
||||||
result ^= result << 12;
|
return hash;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +121,6 @@ AttrHashString(const char* string, uint32 type)
|
|||||||
hash = (hash << 7) ^ (hash >> 24);
|
hash = (hash << 7) ^ (hash >> 24);
|
||||||
hash ^= c;
|
hash ^= c;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash ^= hash << 12;
|
hash ^= hash << 12;
|
||||||
|
|
||||||
hash &= ~0xff;
|
hash &= ~0xff;
|
||||||
@@ -557,22 +556,22 @@ FadeRGBA32Vertical(uint32* bits, int32 width, int32 height, int32 from,
|
|||||||
|
|
||||||
|
|
||||||
DraggableIcon::DraggableIcon(BRect rect, const char* name,
|
DraggableIcon::DraggableIcon(BRect rect, const char* name,
|
||||||
const char* mimeType, icon_size size, const BMessage* message,
|
const char* mimeType, icon_size which, const BMessage* message,
|
||||||
BMessenger target, uint32 resizeMask, uint32 flags)
|
BMessenger target, uint32 resizingMode, uint32 flags)
|
||||||
:
|
:
|
||||||
BView(rect, name, resizeMask, flags),
|
BView(rect, name, resizingMode, flags),
|
||||||
fMessage(*message),
|
fMessage(*message),
|
||||||
fTarget(target)
|
fTarget(target)
|
||||||
{
|
{
|
||||||
fBitmap = new BBitmap(Bounds(), kDefaultIconDepth);
|
fBitmap = new BBitmap(Bounds(), kDefaultIconDepth);
|
||||||
BMimeType mime(mimeType);
|
BMimeType mime(mimeType);
|
||||||
status_t error = mime.GetIcon(fBitmap, size);
|
status_t result = mime.GetIcon(fBitmap, which);
|
||||||
ASSERT(mime.IsValid());
|
ASSERT(mime.IsValid());
|
||||||
if (error != B_OK) {
|
if (result != B_OK) {
|
||||||
PRINT(("failed to get icon for %s, %s\n", mimeType, strerror(error)));
|
PRINT(("failed to get icon for %s, %s\n", mimeType, strerror(result)));
|
||||||
BMimeType mime(B_FILE_MIMETYPE);
|
BMimeType mime(B_FILE_MIMETYPE);
|
||||||
ASSERT(mime.IsInstalled());
|
ASSERT(mime.IsInstalled());
|
||||||
mime.GetIcon(fBitmap, size);
|
mime.GetIcon(fBitmap, which);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,11 +590,11 @@ DraggableIcon::SetTarget(BMessenger target)
|
|||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
DraggableIcon::PreferredRect(BPoint offset, icon_size size)
|
DraggableIcon::PreferredRect(BPoint offset, icon_size which)
|
||||||
{
|
{
|
||||||
BRect result(0, 0, size - 1, size - 1);
|
BRect rect(0, 0, which - 1, which - 1);
|
||||||
result.OffsetTo(offset);
|
rect.OffsetTo(offset);
|
||||||
return result;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -661,21 +660,21 @@ DraggableIcon::Draw(BRect)
|
|||||||
|
|
||||||
|
|
||||||
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
const char* text, uint32 resizeFlags, uint32 flags)
|
const char* text, uint32 resizingMode, uint32 flags)
|
||||||
:
|
:
|
||||||
BStringView(bounds, name, text, resizeFlags, flags),
|
BStringView(bounds, name, text, resizingMode, flags),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fOrigBitmap(NULL)
|
fOriginalBitmap(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView::FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
const char* text, BBitmap* inBitmap, uint32 resizeFlags, uint32 flags)
|
const char* text, BBitmap* inBitmap, uint32 resizingMode, uint32 flags)
|
||||||
:
|
:
|
||||||
BStringView(bounds, name, text, resizeFlags, flags),
|
BStringView(bounds, name, text, resizingMode, flags),
|
||||||
fBitmap(NULL),
|
fBitmap(NULL),
|
||||||
fOrigBitmap(inBitmap)
|
fOriginalBitmap(inBitmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,7 +689,7 @@ void
|
|||||||
FlickerFreeStringView::Draw(BRect)
|
FlickerFreeStringView::Draw(BRect)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
if (!fBitmap)
|
if (fBitmap == NULL)
|
||||||
fBitmap = new OffscreenBitmap(Bounds());
|
fBitmap = new OffscreenBitmap(Bounds());
|
||||||
|
|
||||||
BView* offscreen = fBitmap->BeginUsing(bounds);
|
BView* offscreen = fBitmap->BeginUsing(bounds);
|
||||||
@@ -709,8 +708,8 @@ FlickerFreeStringView::Draw(BRect)
|
|||||||
offscreen->SetFont(&font);
|
offscreen->SetFont(&font);
|
||||||
|
|
||||||
offscreen->Sync();
|
offscreen->Sync();
|
||||||
if (fOrigBitmap)
|
if (fOriginalBitmap != NULL)
|
||||||
offscreen->DrawBitmap(fOrigBitmap, Frame(), bounds);
|
offscreen->DrawBitmap(fOriginalBitmap, Frame(), bounds);
|
||||||
else
|
else
|
||||||
offscreen->FillRect(bounds, B_SOLID_LOW);
|
offscreen->FillRect(bounds, B_SOLID_LOW);
|
||||||
|
|
||||||
@@ -952,8 +951,9 @@ ShortcutFilter::Filter(BMessage* message, BHandler**)
|
|||||||
if (message->FindInt32("modifiers", (int32*)&modifiers) != B_OK
|
if (message->FindInt32("modifiers", (int32*)&modifiers) != B_OK
|
||||||
|| message->FindInt32("raw_char", (int32*)&rawKeyChar) != B_OK
|
|| message->FindInt32("raw_char", (int32*)&rawKeyChar) != B_OK
|
||||||
|| message->FindInt8("byte", (int8*)&byte) != B_OK
|
|| message->FindInt8("byte", (int8*)&byte) != B_OK
|
||||||
|| message->FindInt32("key", &key) != B_OK)
|
|| message->FindInt32("key", &key) != B_OK) {
|
||||||
return B_DISPATCH_MESSAGE;
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}
|
||||||
|
|
||||||
modifiers &= B_SHIFT_KEY | B_COMMAND_KEY | B_CONTROL_KEY
|
modifiers &= B_SHIFT_KEY | B_COMMAND_KEY | B_CONTROL_KEY
|
||||||
| B_OPTION_KEY | B_MENU_KEY;
|
| B_OPTION_KEY | B_MENU_KEY;
|
||||||
@@ -995,18 +995,21 @@ EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MatchArchivedVolume(BVolume* result, const BMessage* message, int32 index)
|
MatchArchivedVolume(BVolume* volume, const BMessage* message, int32 index)
|
||||||
{
|
{
|
||||||
time_t created;
|
time_t created;
|
||||||
off_t capacity;
|
off_t capacity;
|
||||||
|
|
||||||
if (message->FindInt32("creationDate", index, &created) != B_OK
|
if (message->FindInt32("creationDate", index, &created) != B_OK
|
||||||
|| message->FindInt64("capacity", index, &capacity) != B_OK)
|
|| message->FindInt64("capacity", index, &capacity) != B_OK) {
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
BVolumeRoster roster;
|
BVolumeRoster roster;
|
||||||
BVolume volume;
|
BVolume tempVolume;
|
||||||
BString deviceName, volumeName, fshName;
|
BString deviceName;
|
||||||
|
BString volumeName;
|
||||||
|
BString fshName;
|
||||||
|
|
||||||
if (message->FindString("deviceName", &deviceName) == B_OK
|
if (message->FindString("deviceName", &deviceName) == B_OK
|
||||||
&& message->FindString("volumeName", &volumeName) == B_OK
|
&& message->FindString("volumeName", &volumeName) == B_OK
|
||||||
@@ -1019,60 +1022,65 @@ MatchArchivedVolume(BVolume* result, const BMessage* message, int32 index)
|
|||||||
dev_t foundDevice = -1;
|
dev_t foundDevice = -1;
|
||||||
int foundScore = -1;
|
int foundScore = -1;
|
||||||
roster.Rewind();
|
roster.Rewind();
|
||||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
while (roster.GetNextVolume(&tempVolume) == B_OK) {
|
||||||
if (volume.IsPersistent() && volume.KnowsQuery()) {
|
if (tempVolume.IsPersistent() && tempVolume.KnowsQuery()) {
|
||||||
// get creation time and fs_info
|
// get creation time and fs_info
|
||||||
BDirectory root;
|
BDirectory root;
|
||||||
volume.GetRootDirectory(&root);
|
tempVolume.GetRootDirectory(&root);
|
||||||
time_t cmpCreated;
|
time_t cmpCreated;
|
||||||
fs_info info;
|
fs_info info;
|
||||||
if (root.GetCreationTime(&cmpCreated) == B_OK
|
if (root.GetCreationTime(&cmpCreated) == B_OK
|
||||||
&& fs_stat_dev(volume.Device(), &info) == 0) {
|
&& fs_stat_dev(tempVolume.Device(), &info) == 0) {
|
||||||
// compute the score
|
// compute the score
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
// creation time
|
// creation time
|
||||||
if (created == cmpCreated)
|
if (created == cmpCreated)
|
||||||
score += 5;
|
score += 5;
|
||||||
|
|
||||||
// capacity
|
// capacity
|
||||||
if (capacity == volume.Capacity())
|
if (capacity == tempVolume.Capacity())
|
||||||
score += 4;
|
score += 4;
|
||||||
|
|
||||||
// device name
|
// device name
|
||||||
if (deviceName == info.device_name)
|
if (deviceName == info.device_name)
|
||||||
score += 3;
|
score += 3;
|
||||||
|
|
||||||
// volume name
|
// volume name
|
||||||
if (volumeName == info.volume_name)
|
if (volumeName == info.volume_name)
|
||||||
score += 2;
|
score += 2;
|
||||||
|
|
||||||
// fsh name
|
// fsh name
|
||||||
if (fshName == info.fsh_name)
|
if (fshName == info.fsh_name)
|
||||||
score += 1;
|
score += 1;
|
||||||
|
|
||||||
// check score
|
// check score
|
||||||
if (score >= 9 && score > foundScore) {
|
if (score >= 9 && score > foundScore) {
|
||||||
foundDevice = volume.Device();
|
foundDevice = tempVolume.Device();
|
||||||
foundScore = score;
|
foundScore = score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (foundDevice >= 0)
|
if (foundDevice >= 0)
|
||||||
return result->SetTo(foundDevice);
|
return volume->SetTo(foundDevice);
|
||||||
} else {
|
} else {
|
||||||
// Old style volume identifiers: We have only creation time and
|
// Old style volume identifiers: We have only creation time and
|
||||||
// capacity. Both must match.
|
// capacity. Both must match.
|
||||||
roster.Rewind();
|
roster.Rewind();
|
||||||
while (roster.GetNextVolume(&volume) == B_OK)
|
while (roster.GetNextVolume(&tempVolume) == B_OK) {
|
||||||
if (volume.IsPersistent() && volume.KnowsQuery()) {
|
if (tempVolume.IsPersistent() && tempVolume.KnowsQuery()) {
|
||||||
BDirectory root;
|
BDirectory root;
|
||||||
volume.GetRootDirectory(&root);
|
tempVolume.GetRootDirectory(&root);
|
||||||
time_t cmpCreated;
|
time_t cmpCreated;
|
||||||
root.GetCreationTime(&cmpCreated);
|
root.GetCreationTime(&cmpCreated);
|
||||||
if (created == cmpCreated && capacity == volume.Capacity()) {
|
if (created == cmpCreated && capacity == tempVolume.Capacity()) {
|
||||||
*result = volume;
|
*volume = tempVolume;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return B_DEV_BAD_DRIVE_NUM;
|
return B_DEV_BAD_DRIVE_NUM;
|
||||||
}
|
}
|
||||||
@@ -1140,9 +1148,9 @@ EachEntryRefCommon(BMessage* message, entry_ref *(*func)(entry_ref*, void*),
|
|||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
message->FindRef("refs", index, &ref);
|
message->FindRef("refs", index, &ref);
|
||||||
entry_ref* result = (func)(&ref, passThru);
|
entry_ref* newRef = (func)(&ref, passThru);
|
||||||
if (result)
|
if (newRef != NULL)
|
||||||
return result;
|
return newRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1246,15 +1254,15 @@ StringToScalar(const char* text)
|
|||||||
static BRect
|
static BRect
|
||||||
LineBounds(BPoint where, float length, bool vertical)
|
LineBounds(BPoint where, float length, bool vertical)
|
||||||
{
|
{
|
||||||
BRect result;
|
BRect rect;
|
||||||
result.SetLeftTop(where);
|
rect.SetLeftTop(where);
|
||||||
result.SetRightBottom(where + BPoint(2, 2));
|
rect.SetRightBottom(where + BPoint(2, 2));
|
||||||
if (vertical)
|
if (vertical)
|
||||||
result.bottom = result.top + length;
|
rect.bottom = rect.top + length;
|
||||||
else
|
else
|
||||||
result.right = result.left + length;
|
rect.right = rect.left + length;
|
||||||
|
|
||||||
return result;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1332,7 +1340,7 @@ void
|
|||||||
EnableNamedMenuItem(BMenu* menu, const char* itemName, bool on)
|
EnableNamedMenuItem(BMenu* menu, const char* itemName, bool on)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(itemName);
|
BMenuItem* item = menu->FindItem(itemName);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetEnabled(on);
|
item->SetEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1341,7 +1349,7 @@ void
|
|||||||
MarkNamedMenuItem(BMenu* menu, const char* itemName, bool on)
|
MarkNamedMenuItem(BMenu* menu, const char* itemName, bool on)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(itemName);
|
BMenuItem* item = menu->FindItem(itemName);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(on);
|
item->SetMarked(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,7 +1358,7 @@ void
|
|||||||
EnableNamedMenuItem(BMenu* menu, uint32 commandName, bool on)
|
EnableNamedMenuItem(BMenu* menu, uint32 commandName, bool on)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(commandName);
|
BMenuItem* item = menu->FindItem(commandName);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetEnabled(on);
|
item->SetEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1359,7 +1367,7 @@ void
|
|||||||
MarkNamedMenuItem(BMenu* menu, uint32 commandName, bool on)
|
MarkNamedMenuItem(BMenu* menu, uint32 commandName, bool on)
|
||||||
{
|
{
|
||||||
BMenuItem* item = menu->FindItem(commandName);
|
BMenuItem* item = menu->FindItem(commandName);
|
||||||
if (item)
|
if (item != NULL)
|
||||||
item->SetMarked(on);
|
item->SetMarked(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1367,16 +1375,16 @@ MarkNamedMenuItem(BMenu* menu, uint32 commandName, bool on)
|
|||||||
void
|
void
|
||||||
DeleteSubmenu(BMenuItem* submenuItem)
|
DeleteSubmenu(BMenuItem* submenuItem)
|
||||||
{
|
{
|
||||||
if (!submenuItem)
|
if (submenuItem == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BMenu* menu = submenuItem->Submenu();
|
BMenu* menu = submenuItem->Submenu();
|
||||||
if (!menu)
|
if (menu == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
BMenuItem* item = menu->RemoveItem((int32)0);
|
BMenuItem* item = menu->RemoveItem((int32)0);
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
@@ -1385,7 +1393,7 @@ DeleteSubmenu(BMenuItem* submenuItem)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GetAppSignatureFromAttr(BFile* file, char* result)
|
GetAppSignatureFromAttr(BFile* file, char* attr)
|
||||||
{
|
{
|
||||||
// This call is a performance improvement that
|
// This call is a performance improvement that
|
||||||
// avoids using the BAppFileInfo API when retrieving the
|
// avoids using the BAppFileInfo API when retrieving the
|
||||||
@@ -1394,10 +1402,10 @@ GetAppSignatureFromAttr(BFile* file, char* result)
|
|||||||
|
|
||||||
#ifdef B_APP_FILE_INFO_IS_FAST
|
#ifdef B_APP_FILE_INFO_IS_FAST
|
||||||
BAppFileInfo appFileInfo(file);
|
BAppFileInfo appFileInfo(file);
|
||||||
return appFileInfo.GetSignature(result);
|
return appFileInfo.GetSignature(attr);
|
||||||
#else
|
#else
|
||||||
ssize_t readResult = file->ReadAttr(kAttrAppSignature, B_MIME_STRING_TYPE,
|
ssize_t readResult = file->ReadAttr(kAttrAppSignature, B_MIME_STRING_TYPE,
|
||||||
0, result, B_MIME_TYPE_LENGTH);
|
0, attr, B_MIME_TYPE_LENGTH);
|
||||||
|
|
||||||
if (readResult <= 0)
|
if (readResult <= 0)
|
||||||
return (status_t)readResult;
|
return (status_t)readResult;
|
||||||
@@ -1462,10 +1470,10 @@ GetAppIconFromAttr(BFile* file, BBitmap* icon, icon_size which)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
GetFileIconFromAttr(BNode* node, BBitmap* icon, icon_size size)
|
GetFileIconFromAttr(BNode* node, BBitmap* icon, icon_size which)
|
||||||
{
|
{
|
||||||
BNodeInfo fileInfo(node);
|
BNodeInfo fileInfo(node);
|
||||||
return fileInfo.GetIcon(icon, size);
|
return fileInfo.GetIcon(icon, which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1483,13 +1491,13 @@ EachMenuItem(BMenu* menu, bool recursive, BMenuItem* (*func)(BMenuItem *))
|
|||||||
int32 count = menu->CountItems();
|
int32 count = menu->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BMenuItem* item = menu->ItemAt(index);
|
BMenuItem* item = menu->ItemAt(index);
|
||||||
BMenuItem* result = (func)(item);
|
BMenuItem* newItem = (func)(item);
|
||||||
if (result != NULL)
|
if (newItem != NULL)
|
||||||
return result;
|
return newItem;
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
BMenu* submenu = menu->SubmenuAt(index);
|
BMenu* submenu = menu->SubmenuAt(index);
|
||||||
if (submenu)
|
if (submenu != NULL)
|
||||||
return EachMenuItem(submenu, true, func);
|
return EachMenuItem(submenu, true, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1505,13 +1513,13 @@ EachMenuItem(const BMenu* menu, bool recursive,
|
|||||||
int32 count = menu->CountItems();
|
int32 count = menu->CountItems();
|
||||||
for (int32 index = 0; index < count; index++) {
|
for (int32 index = 0; index < count; index++) {
|
||||||
BMenuItem* item = menu->ItemAt(index);
|
BMenuItem* item = menu->ItemAt(index);
|
||||||
BMenuItem* result = (func)(item);
|
BMenuItem* newItem = (func)(item);
|
||||||
if (result)
|
if (newItem != NULL)
|
||||||
return result;
|
return newItem;
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
BMenu* submenu = menu->SubmenuAt(index);
|
BMenu* submenu = menu->SubmenuAt(index);
|
||||||
if (submenu)
|
if (submenu != NULL)
|
||||||
return EachMenuItem(submenu, true, func);
|
return EachMenuItem(submenu, true, func);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1644,12 +1652,12 @@ ComputeTypeAheadScore(const char* text, const char* match, bool wordMode)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_ThrowOnError(status_t error, const char* DEBUG_ONLY(file),
|
_ThrowOnError(status_t result, const char* DEBUG_ONLY(file),
|
||||||
int32 DEBUG_ONLY(line))
|
int32 DEBUG_ONLY(line))
|
||||||
{
|
{
|
||||||
if (error != B_OK) {
|
if (result != B_OK) {
|
||||||
PRINT(("failing %s at %s:%d\n", strerror(error), file, (int)line));
|
PRINT(("failing %s at %s:%d\n", strerror(result), file, (int)line));
|
||||||
throw error;
|
throw result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1666,13 +1674,13 @@ _ThrowIfNotSize(ssize_t size, const char* DEBUG_ONLY(file),
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_ThrowOnError(status_t error, const char* DEBUG_ONLY(debugString),
|
_ThrowOnError(status_t result, const char* DEBUG_ONLY(debugString),
|
||||||
const char* DEBUG_ONLY(file), int32 DEBUG_ONLY(line))
|
const char* DEBUG_ONLY(file), int32 DEBUG_ONLY(line))
|
||||||
{
|
{
|
||||||
if (error != B_OK) {
|
if (result != B_OK) {
|
||||||
PRINT(("failing %s, %s at %s:%d\n", debugString, strerror(error), file,
|
PRINT(("failing %s, %s at %s:%d\n", debugString, strerror(result), file,
|
||||||
(int)line));
|
(int)line));
|
||||||
throw error;
|
throw result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,11 +223,11 @@ class FlickerFreeStringView : public BStringView {
|
|||||||
// often this would be better implemented as an option of BStringView
|
// often this would be better implemented as an option of BStringView
|
||||||
public:
|
public:
|
||||||
FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
const char* text, uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
const char* text, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
FlickerFreeStringView(BRect bounds, const char* name,
|
FlickerFreeStringView(BRect bounds, const char* name,
|
||||||
const char* text, BBitmap* existingOffscreen,
|
const char* text, BBitmap* existingOffscreen,
|
||||||
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
virtual ~FlickerFreeStringView();
|
virtual ~FlickerFreeStringView();
|
||||||
virtual void Draw(BRect);
|
virtual void Draw(BRect);
|
||||||
@@ -239,7 +239,7 @@ private:
|
|||||||
OffscreenBitmap* fBitmap;
|
OffscreenBitmap* fBitmap;
|
||||||
rgb_color fViewColor;
|
rgb_color fViewColor;
|
||||||
rgb_color fLowColor;
|
rgb_color fLowColor;
|
||||||
BBitmap* fOrigBitmap;
|
BBitmap* fOriginalBitmap;
|
||||||
|
|
||||||
typedef BStringView _inherited;
|
typedef BStringView _inherited;
|
||||||
};
|
};
|
||||||
@@ -248,13 +248,13 @@ private:
|
|||||||
class DraggableIcon : public BView {
|
class DraggableIcon : public BView {
|
||||||
// used to determine a save location for a file
|
// used to determine a save location for a file
|
||||||
public:
|
public:
|
||||||
DraggableIcon(BRect, const char*, const char* mimeType, icon_size,
|
DraggableIcon(BRect rect, const char* name, const char* mimeType,
|
||||||
const BMessage*, BMessenger,
|
icon_size which, const BMessage* message, BMessenger target,
|
||||||
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
virtual ~DraggableIcon();
|
virtual ~DraggableIcon();
|
||||||
|
|
||||||
static BRect PreferredRect(BPoint offset, icon_size);
|
static BRect PreferredRect(BPoint offset, icon_size which);
|
||||||
void SetTarget(BMessenger);
|
void SetTarget(BMessenger);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -420,8 +420,9 @@ int64 StringToScalar(const char* text);
|
|||||||
// string to num, understands kB, MB, etc.
|
// string to num, understands kB, MB, etc.
|
||||||
|
|
||||||
// misc calls
|
// misc calls
|
||||||
void EmbedUniqueVolumeInfo(BMessage*, const BVolume*);
|
void EmbedUniqueVolumeInfo(BMessage* message, const BVolume* volume);
|
||||||
status_t MatchArchivedVolume(BVolume*, const BMessage*, int32 index = 0);
|
status_t MatchArchivedVolume(BVolume* volume, const BMessage* message,
|
||||||
|
int32 index = 0);
|
||||||
void TruncateLeaf(BString* string);
|
void TruncateLeaf(BString* string);
|
||||||
|
|
||||||
void StringFromStream(BString*, BMallocIO*, bool endianSwap = false);
|
void StringFromStream(BString*, BMallocIO*, bool endianSwap = false);
|
||||||
@@ -464,22 +465,24 @@ template <class InitCheckable>
|
|||||||
void
|
void
|
||||||
ThrowOnInitCheckError(InitCheckable* item)
|
ThrowOnInitCheckError(InitCheckable* item)
|
||||||
{
|
{
|
||||||
if (!item)
|
if (item == NULL)
|
||||||
throw (status_t)B_ERROR;
|
throw (status_t)B_ERROR;
|
||||||
|
|
||||||
status_t error = item->InitCheck();
|
status_t result = item->InitCheck();
|
||||||
if (error != B_OK)
|
if (result != B_OK)
|
||||||
throw (status_t)error;
|
throw (status_t)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#define ThrowOnError(error) _ThrowOnError(error, __FILE__, __LINE__)
|
# define ThrowOnError(result) _ThrowOnError(result, __FILE__, __LINE__)
|
||||||
#define ThrowIfNotSize(error) _ThrowIfNotSize(error, __FILE__, __LINE__)
|
# define ThrowIfNotSize(result) _ThrowIfNotSize(result, __FILE__, __LINE__)
|
||||||
#define ThrowOnErrorWithMessage(error, debugStr) _ThrowOnError(error, debugStr, __FILE__, __LINE__)
|
# define ThrowOnErrorWithMessage(result, debugStr) \
|
||||||
|
_ThrowOnError(result, debugStr, __FILE__, __LINE__)
|
||||||
#else
|
#else
|
||||||
#define ThrowOnError(x) _ThrowOnError(x, 0, 0)
|
# define ThrowOnError(x) _ThrowOnError(x, 0, 0)
|
||||||
#define ThrowIfNotSize(x) _ThrowIfNotSize(x, 0, 0)
|
# define ThrowIfNotSize(x) _ThrowIfNotSize(x, 0, 0)
|
||||||
#define ThrowOnErrorWithMessage(error, debugStr) _ThrowOnError(error, debugStr, __FILE__, __LINE__)
|
# define ThrowOnErrorWithMessage(result, debugStr) \
|
||||||
|
_ThrowOnError(result, debugStr, __FILE__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void _ThrowOnError(status_t, const char*, int32);
|
void _ThrowOnError(status_t, const char*, int32);
|
||||||
|
|||||||
Reference in New Issue
Block a user