Skip to content

Commit

Permalink
[FIX] : fix crash when the code generaotr module was destroyed with s…
Browse files Browse the repository at this point in the history
…elected slots
  • Loading branch information
aiekick committed Nov 19, 2023
1 parent ed0d6ca commit b0f9290
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 109 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX _debug)
endif()

file(GLOB PROJECT_MAIN ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
file(GLOB PROJECT_MAIN
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
source_group(main FILES ${PROJECT_MAIN})

file(GLOB PROJECT_MISC
${CMAKE_CURRENT_SOURCE_DIR}/.clang-format)
source_group(misc FILES ${PROJECT_MISC})

file(GLOB_RECURSE PROJECT_CMAKE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/cmake PREFIX cmake FILES ${PROJECT_CMAKE_FILES})
Expand Down Expand Up @@ -189,6 +194,7 @@ add_executable(${PROJECT}
${README_MD}
${GITHUB_FILES}
${PROJECT_MAIN}
${PROJECT_MISC}
${PLUGINS_README_MD}
${PROJECT_DOC_FILES}
${PROJECT_SRC_FILES}
Expand Down
8 changes: 8 additions & 0 deletions Plugins/CodeGenerator/src/Editor/SlotEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ NodeSlotWeak SlotEditor::DrawSlotCreationPane(
res = std::dynamic_pointer_cast<GeneratorNodeSlotInput>(
nodePtr->AddInput(GeneratorNodeSlotInput::Create("New Slot"), false, false).lock());
NodeSlot::sSlotGraphOutputMouseMiddle = res;
auto slot_ptr = res.lock();
if (slot_ptr != nullptr) {
slot_ptr->descriptorBinding = nodePtr->m_Inputs.size() - 1U;
}
} else if (vPlace == NodeSlot::PlaceEnum::OUTPUT) {
res = std::dynamic_pointer_cast<GeneratorNodeSlotOutput>(
nodePtr->AddOutput(GeneratorNodeSlotOutput::Create("New Slot"), false, false).lock());
NodeSlot::sSlotGraphOutputMouseRight = res;
auto slot_ptr = res.lock();
if (slot_ptr != nullptr) {
slot_ptr->descriptorBinding = nodePtr->m_Inputs.size() - 1U;
}
}
SelectSlot(res);
ImGui::EndChild();
Expand Down
16 changes: 3 additions & 13 deletions Plugins/CodeGenerator/src/Editor/UBOEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,35 +407,27 @@ std::string UBOItem::Get_Cpp_Item_Widget(const std::string& vStage, const int32_

std::string UBOItem::getXml(const std::string& vOffset, const std::string& vUserDatas) {
UNUSED(vUserDatas);

std::string str;

str += vOffset + ct::toStr("<UBOItem name=\"%s\" widgetIndex=\"%u\" typeIndex=\"%u\" vx=\"%s\" vy=\"%s\" vz=\"%s\" vw=\"%s\" CheckBoxDefault=\"%s\" ColorRGBDefault=\"%s\" ColorRGBADefault=\"%s\"/>\n", m_InputName.GetText().c_str(),
m_WidgetIndex, m_InputTypeIndex, m_InputValue_x.GetText().c_str(), m_InputValue_y.GetText().c_str(), m_InputValue_z.GetText().c_str(), m_InputValue_w.GetText().c_str(),
m_CheckBoxItem_DefaultValue ? "true" : "false", m_ColorRGBItem_DefaultValue.string().c_str(), m_ColorRGBAItem_DefaultValue.string().c_str());

return str;
}

bool UBOItem::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent, const std::string& vUserDatas) {
UNUSED(vUserDatas);

// The value of this child identifies the name of this element
std::string strName;
std::string strValue;
std::string strParentName;

strName = vElem->Value();
if (vElem->GetText())
strValue = vElem->GetText();
if (vParent != 0)
strParentName = vParent->Value();

if (strName == "UBOItem") {
for (const tinyxml2::XMLAttribute* attr = vElem->FirstAttribute(); attr != nullptr; attr = attr->Next()) {
std::string attName = attr->Name();
std::string attValue = attr->Value();

const std::string& attName = attr->Name();
const std::string& attValue = attr->Value();
if (attName == "name")
m_InputName.SetText(attValue);
else if (attName == "widgetIndex")
Expand All @@ -456,7 +448,6 @@ bool UBOItem::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vPar
m_ColorRGBItem_DefaultValue = ct::fvariant(attValue).GetV3();
else if (attName == "ColorRGBADefault")
m_ColorRGBAItem_DefaultValue = ct::fvariant(attValue).GetV4();

}
}

Expand Down Expand Up @@ -648,8 +639,7 @@ std::string UBOEditor::Get_Glsl_Header(

std::string res = ct::toStr(
u8R"(
layout(std140, binding = %i) uniform @UBO_NAME@
{)",
layout(std140, binding = %i) uniform @UBO_NAME@ {)",
vUboBindingIndex);

for (auto item : m_Items) {
Expand Down
4 changes: 2 additions & 2 deletions Plugins/CodeGenerator/src/Headers/CodeGeneratorBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define CodeGenerator_Prefix "CodeGenerator"
#define CodeGenerator_BuildNumber 628
#define CodeGenerator_BuildNumber 634
#define CodeGenerator_MinorNumber 0
#define CodeGenerator_MajorNumber 0
#define CodeGenerator_BuildId "0.0.628"
#define CodeGenerator_BuildId "0.0.634"
Loading

0 comments on commit b0f9290

Please sign in to comment.