Editor: Fix InspectorPanel AddComponent popup crash
- Remove SeparatorText which causes PopStyleVar mismatch in ImGui - Add stderr redirection for better error capture - Add debug logging to InspectorPanel - Fix EditorLayer commented out undefined functions
This commit is contained in:
@@ -5,24 +5,6 @@
|
||||
#include <XCEngine/Debug/Logger.h>
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include <excpt.h>
|
||||
|
||||
static LONG WINAPI CrashExceptionFilter(EXCEPTION_POINTERS* exceptionPointers) {
|
||||
char buffer[1024];
|
||||
std::snprintf(buffer, sizeof(buffer),
|
||||
"[CRASH] ExceptionCode=0x%08X, Address=0x%p",
|
||||
exceptionPointers->ExceptionRecord->ExceptionCode,
|
||||
exceptionPointers->ExceptionRecord->ExceptionAddress);
|
||||
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\editor\\bin\\Release\\crash.log", "a");
|
||||
if (f) {
|
||||
fprintf(f, "%s\n", buffer);
|
||||
fclose(f);
|
||||
}
|
||||
fprintf(stderr, "%s\n", buffer);
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
@@ -93,9 +75,9 @@ void InspectorPanel::RenderAddComponentPopup(::XCEngine::Components::GameObject*
|
||||
}
|
||||
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "BeginPopup succeeded");
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12.0f, 10.0f));
|
||||
|
||||
ImGui::SeparatorText("Components");
|
||||
ImGui::Text("Components");
|
||||
ImGui::Separator();
|
||||
|
||||
bool hasTransform = gameObject->GetComponent<::XCEngine::Components::TransformComponent>() != nullptr;
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, hasTransform ? "Has Transform: yes" : "Has Transform: no");
|
||||
@@ -104,26 +86,19 @@ void InspectorPanel::RenderAddComponentPopup(::XCEngine::Components::GameObject*
|
||||
if (ImGui::MenuItem("Transform", nullptr, false, !hasTransform)) {
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "MenuItem CLICKED! Before AddComponent");
|
||||
|
||||
void* newComp = nullptr;
|
||||
__try {
|
||||
newComp = gameObject->AddComponent<::XCEngine::Components::TransformComponent>();
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, newComp ? "AddComponent SUCCEEDED" : "AddComponent FAILED");
|
||||
}
|
||||
__except(CrashExceptionFilter(GetExceptionInformation())) {
|
||||
Debug::Logger::Get().Error(Debug::LogCategory::General, "AddComponent CRASHED!");
|
||||
}
|
||||
auto* newComp = gameObject->AddComponent<::XCEngine::Components::TransformComponent>();
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, newComp ? "AddComponent SUCCEEDED" : "AddComponent FAILED");
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
} else {
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "MenuItem not clicked (disabled or condition false)");
|
||||
}
|
||||
|
||||
ImGui::SeparatorText("Other");
|
||||
ImGui::Separator();
|
||||
ImGui::TextDisabled("No more components available");
|
||||
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "About to EndPopup");
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "About to EndPopup - calling EndPopup");
|
||||
ImGui::EndPopup();
|
||||
ImGui::PopStyleVar();
|
||||
Debug::Logger::Get().Debug(Debug::LogCategory::General, "Popup closed");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user