Screenshot

* Fix violations to coding guidelines
 * Error checks on the received entry_refs
 * Typo in comment

Thanks Axel!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40843 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Saint-Pierre 2011-03-06 14:14:37 +00:00
parent d099bb8b90
commit d020e3568f

View File

@ -332,11 +332,15 @@ ScreenshotWindow::MessageReceived(BMessage* message)
entry_ref ref; entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) { if (message->FindRef("refs", &ref) == B_OK) {
BEntry entry(&ref, true); BEntry entry(&ref, true);
if (entry.InitCheck() == B_OK) {
BPath path; BPath path;
entry.GetPath(&path); // Could return B_BUSY
if (entry.GetPath(&path) == B_OK) {
BString label(path.Path()); BString label(path.Path());
_AddItemToPathMenu(path.Path(), label, 3, true); _AddItemToPathMenu(path.Path(), label, 3, true);
} }
}
}
break; break;
} }
@ -514,23 +518,22 @@ void
ScreenshotWindow::_AddItemToPathMenu(const char* path, BString& label, ScreenshotWindow::_AddItemToPathMenu(const char* path, BString& label,
int32 index, bool markItem) int32 index, bool markItem)
{ {
/* Make sure that item won't be a duplicata of an existing one */ // Make sure that item won't be a duplicate of an existing one
for (int32 i = fOutputPathMenu->CountItems(); i > 0; --i) { for (int32 i = fOutputPathMenu->CountItems() - 1; i >= 0; --i) {
BMenuItem* menuItem = fOutputPathMenu->ItemAt(i - 1); BMenuItem* menuItem = fOutputPathMenu->ItemAt(i);
BMessage* message = menuItem->Message(); BMessage* message = menuItem->Message();
const char* pathFromItem; const char* pathFromItem;
if (message != NULL && message->what == kLocationChanged) { if (message != NULL && message->what == kLocationChanged
if (message->FindString("path", &pathFromItem) == B_OK) { && message->FindString("path", &pathFromItem) == B_OK
if (!strcmp(path, pathFromItem)) { && !strcmp(path, pathFromItem)) {
if (markItem) { if (markItem) {
fOutputPathMenu->ItemAt(i - 1)->SetMarked(true); fOutputPathMenu->ItemAt(i)->SetMarked(true);
fLastSelectedPath = fOutputPathMenu->ItemAt(i - 1); fLastSelectedPath = fOutputPathMenu->ItemAt(i);
} }
return; return;
} }
} }
}
}
BMessage* message = new BMessage(kLocationChanged); BMessage* message = new BMessage(kLocationChanged);
message->AddString("path", path); message->AddString("path", path);