From 91b674a00c1c84a8b0690fa0bb5c6cb46a1fc005 Mon Sep 17 00:00:00 2001 From: eytienne Date: Fri, 17 Nov 2023 15:47:30 +0100 Subject: [PATCH 1/3] Fixed null check in Graph::propertyEditor() --- source/MaterialXGraphEditor/Graph.cpp | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/source/MaterialXGraphEditor/Graph.cpp b/source/MaterialXGraphEditor/Graph.cpp index 88ee10a4c1..9191b78885 100644 --- a/source/MaterialXGraphEditor/Graph.cpp +++ b/source/MaterialXGraphEditor/Graph.cpp @@ -240,7 +240,7 @@ mx::DocumentPtr Graph::loadDocument(mx::FilePath filename) std::cerr << "*** Validation warnings for " << filename.asString() << " ***" << std::endl; std::cerr << message << std::endl; } - + // Cache the currently loaded file _materialFilename = filename; } @@ -2102,11 +2102,11 @@ mx::InputPtr Graph::findInput(mx::InputPtr nodeInput, const std::string& name) { if (_isNodeGraph) { - for (UiNodePtr node : _graphNodes) + for (UiNodePtr uiNode : _graphNodes) { - if (node->getNode()) + if (uiNode->getNode()) { - for (mx::InputPtr input : node->getNode()->getActiveInputs()) + for (mx::InputPtr input : uiNode->getNode()->getActiveInputs()) { if (input->getInterfaceInput()) { @@ -2547,7 +2547,7 @@ void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId) return; } - // Perform type check + // Perform type check bool typesMatch = (outputPin->_type == inputPin->_type); if (!typesMatch) { @@ -3093,7 +3093,7 @@ void Graph::loadGraphFromFile(bool prompt) _fileDialog.open(); } else - { + { _graphDoc = loadDocument(_materialFilename); // Rebuild the UI @@ -3104,7 +3104,7 @@ void Graph::loadGraphFromFile(bool prompt) _renderer->setDocument(_graphDoc); _renderer->updateMaterials(nullptr); - } + } } void Graph::saveGraphToFile() @@ -3241,7 +3241,7 @@ void Graph::graphButtons() // Create two windows using splitter float paneWidth = (leftPaneWidth - 2.0f); - + float aspectRatio = _renderer->getPixelRatio(); ImVec2 screenSize = ImVec2(paneWidth, paneWidth / aspectRatio); @@ -3249,14 +3249,14 @@ void Graph::graphButtons() ImVec2 tempWindowPos = ImGui::GetCursorPos(); bool cursorInRenderView = mousePos.x > tempWindowPos.x && mousePos.x < (tempWindowPos.x + screenSize.x) && mousePos.y > tempWindowPos.y && mousePos.y < (tempWindowPos.y + screenSize.y); - + ImGuiWindowFlags windowFlags = 0; if (cursorInRenderView) { windowFlags |= ImGuiWindowFlags_NoScrollWithMouse; } - + ImGui::BeginChild("Selection", ImVec2(paneWidth, 0), false, windowFlags); ImVec2 windowPos = ImGui::GetWindowPos(); @@ -3306,16 +3306,16 @@ void Graph::propertyEditor() std::string name = _currUiNode->getNode()->getParent()->createValidChildName(temp); std::vector downstreamNodes = _currUiNode->getOutputConnections(); - for (UiNodePtr nodes : downstreamNodes) + for (UiNodePtr uiNode : downstreamNodes) { - if (nodes->getInput() == nullptr) + if (!uiNode->getInput() && uiNode->getNode()) { - for (mx::InputPtr input : nodes->getNode()->getActiveInputs()) + for (mx::InputPtr input : uiNode->getNode()->getActiveInputs()) { if (input->getConnectedNode() == _currUiNode->getNode()) { _currUiNode->getNode()->setName(name); - nodes->getNode()->setConnectedNode(input->getName(), _currUiNode->getNode()); + uiNode->getNode()->setConnectedNode(input->getName(), _currUiNode->getNode()); } } } @@ -3330,13 +3330,13 @@ void Graph::propertyEditor() { std::string name = _currUiNode->getInput()->getParent()->createValidChildName(temp); std::vector downstreamNodes = _currUiNode->getOutputConnections(); - for (UiNodePtr nodes : downstreamNodes) + for (UiNodePtr uiNode : downstreamNodes) { - if (nodes->getInput() == nullptr) + if (uiNode->getInput() == nullptr) { - if (nodes->getNode()) + if (uiNode->getNode()) { - for (mx::InputPtr input : nodes->getNode()->getActiveInputs()) + for (mx::InputPtr input : uiNode->getNode()->getActiveInputs()) { if (input->getInterfaceInput() == _currUiNode->getInput()) { @@ -3349,7 +3349,7 @@ void Graph::propertyEditor() } else { - nodes->getOutput()->setConnectedNode(_currUiNode->getNode()); + uiNode->getOutput()->setConnectedNode(_currUiNode->getNode()); } } } @@ -3726,7 +3726,7 @@ void Graph::addNodePopup(bool cursor) } } - + ImGui::EndMenu(); } } @@ -3894,7 +3894,7 @@ void Graph::handleRenderViewInputs() { _renderer->setScrollEvent(scrollAmt); } - + } void Graph::drawGraph(ImVec2 mousePos) From d3e20c47014a808e3200d913cf29705929c93304 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Mon, 20 Nov 2023 14:36:01 -0800 Subject: [PATCH 2/3] Remove extra newline Signed-off-by: Jonathan Stone --- source/MaterialXGraphEditor/Graph.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/MaterialXGraphEditor/Graph.cpp b/source/MaterialXGraphEditor/Graph.cpp index 9191b78885..6e5bcff19b 100644 --- a/source/MaterialXGraphEditor/Graph.cpp +++ b/source/MaterialXGraphEditor/Graph.cpp @@ -3726,7 +3726,6 @@ void Graph::addNodePopup(bool cursor) } } - ImGui::EndMenu(); } } From 042812df4af9608b3d0900e1ba2079fbe51afec5 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Mon, 20 Nov 2023 16:02:52 -0800 Subject: [PATCH 3/3] Remove extra newline Signed-off-by: Jonathan Stone --- source/MaterialXGraphEditor/Graph.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/MaterialXGraphEditor/Graph.cpp b/source/MaterialXGraphEditor/Graph.cpp index 6e5bcff19b..bab5df7b58 100644 --- a/source/MaterialXGraphEditor/Graph.cpp +++ b/source/MaterialXGraphEditor/Graph.cpp @@ -3893,7 +3893,6 @@ void Graph::handleRenderViewInputs() { _renderer->setScrollEvent(scrollAmt); } - } void Graph::drawGraph(ImVec2 mousePos)