Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start debugger if a resource icon is missing in StyledItem #385

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/helpers/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ GetFileExtension(const std::string filename)
}


void
status_t
GetVectorIcon(const std::string icon, BBitmap* bitmap)
{
if(bitmap == nullptr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a space after if and before parenthesis? I know it was here before, but since you are touching this code...?

return;
return B_ERROR;

BResources* resources = BApplication::AppResources();
size_t size;
const uint8* rawIcon;
rawIcon = (const uint8*) resources->LoadResource(B_VECTOR_ICON_TYPE, icon.c_str(), &size);
if(rawIcon == nullptr)
return;
return B_ERROR;

BIconUtils::GetVectorIcon(rawIcon, size, bitmap);
return BIconUtils::GetVectorIcon(rawIcon, size, bitmap);
}


Expand Down
2 changes: 1 addition & 1 deletion src/helpers/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct entry_ref;
std::string GetFileName(const std::string filename);
std::string GetFileExtension(const std::string filename);
// Gets an icon from executable's resources
void GetVectorIcon(const std::string icon, BBitmap* bitmap);
status_t GetVectorIcon(const std::string icon, BBitmap* bitmap);


std::string ParseFileArgument(const std::string argument,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/FunctionsOutlineView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ SymbolListItem::SetIconAndTooltip()
toolTip = B_TRANSLATE("Null");
break;
case SymbolKind::EnumMember:
iconName = "emum-member";
iconName = "enum-member";
toolTip = B_TRANSLATE("Enum member");
break;
case SymbolKind::Struct:
Expand Down
10 changes: 7 additions & 3 deletions src/ui/StyledItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,18 @@ StyledItem::DrawIcon(BView* owner, const BRect& itemBounds,
else
iconName.Prepend("dark-");
}
GetVectorIcon(iconName.String(), icon);
BPoint iconStartingPoint(itemBounds.left + 4.0f,
itemBounds.top + (itemBounds.Height() - iconSize) / 2.0f);
if (icon != nullptr) {

if (GetVectorIcon(iconName.String(), icon) == B_OK) {
owner->SetDrawingMode(B_OP_ALPHA);
owner->DrawBitmap(icon, iconStartingPoint);
delete icon;
} else {
BString error(fIconName);
error << ": icon not found!";
debugger(error.String());
}

delete icon;
return BRect(iconStartingPoint, BSize(iconSize, iconSize));
}
Loading