Skip to content

Commit 3c23880

Browse files
authored
fix: breadcrumb ID conflict and empty labels on dictionary navigation (#23)
* fix missing preposition * fix: breadcrumb ID conflict and empty labels on dictionary navigation - Add PushID/PopID around breadcrumb buttons to avoid conflicting IDs when stack has duplicate names - Protect against empty runtime field/property/method names by checking first character - Fall back to (unnamed) label in breadcrumb when name string is empty
1 parent 80add2e commit 3c23880

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

UnityInspector/src/features/inspector/inspector_window.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2566,16 +2566,21 @@ void Inspector::RenderTabContent(InspectedObjectTab& tab)
25662566
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 4));
25672567
for (size_t i = 0; i < tab.navigationStack.size(); ++i)
25682568
{
2569+
ImGui::PushID(static_cast<int>(i));
25692570
if (i > 0)
25702571
{
25712572
ImGui::SameLine();
25722573
ImGui::TextDisabled(">");
25732574
ImGui::SameLine();
25742575
}
2575-
if (ImGui::Button(tab.navigationStack[i].name.c_str()))
2576+
const char* label = tab.navigationStack[i].name.c_str();
2577+
if (label[0] == '\0')
2578+
label = "(unnamed)";
2579+
if (ImGui::Button(label))
25762580
{
25772581
tab.navigationStack.resize(i + 1);
25782582
}
2583+
ImGui::PopID();
25792584
}
25802585
ImGui::PopStyleVar();
25812586
ImGui::Separator();

UnityInspector/src/features/inspector/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::vector<ComponentFieldInfo> Inspector::GetObjectFields(void* obj, void* klas
4343
info.classHandle = currentClass;
4444

4545
const char* fieldName = UR::Invoke<const char*, void*>(API("field_get_name"), field);
46-
info.name = fieldName ? fieldName : "(unknown)";
46+
info.name = fieldName && fieldName[0] ? fieldName : "(unnamed)";
4747

4848
info.offset = UR::Invoke<int, void*>(API("field_get_offset"), field);
4949

@@ -117,7 +117,7 @@ std::vector<ComponentPropertyInfo> Inspector::GetObjectProperties(void* obj, voi
117117
ComponentPropertyInfo info;
118118

119119
const char* propName = UR::Invoke<const char*, void*>(API("property_get_name"), prop);
120-
info.name = propName ? propName : "(unknown)";
120+
info.name = propName && propName[0] ? propName : "(unnamed)";
121121

122122
info.getterHandle = UR::Invoke<void*, void*>(API("property_get_get_method"), prop);
123123
info.setterHandle = UR::Invoke<void*, void*>(API("property_get_set_method"), prop);
@@ -181,7 +181,7 @@ std::vector<ComponentMethodInfo> Inspector::GetObjectMethods(void* obj, void* kl
181181
info.methodHandle = method;
182182

183183
const char* methodName = UR::Invoke<const char*, void*>(API("method_get_name"), method);
184-
info.name = methodName ? methodName : "(unknown)";
184+
info.name = methodName && methodName[0] ? methodName : "(unnamed)";
185185

186186
int fFlags = 0;
187187
info.flags = UR::Invoke<int, void*, int*>(API("method_get_flags"), method, &fFlags);

0 commit comments

Comments
 (0)