Skip to content

Commit 60c8a59

Browse files
authored
Fixed null check in Graph::propertyEditor (#1601)
1 parent 30a446e commit 60c8a59

1 file changed

Lines changed: 19 additions & 21 deletions

File tree

source/MaterialXGraphEditor/Graph.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ mx::DocumentPtr Graph::loadDocument(mx::FilePath filename)
240240
std::cerr << "*** Validation warnings for " << filename.asString() << " ***" << std::endl;
241241
std::cerr << message << std::endl;
242242
}
243-
243+
244244
// Cache the currently loaded file
245245
_materialFilename = filename;
246246
}
@@ -2102,11 +2102,11 @@ mx::InputPtr Graph::findInput(mx::InputPtr nodeInput, const std::string& name)
21022102
{
21032103
if (_isNodeGraph)
21042104
{
2105-
for (UiNodePtr node : _graphNodes)
2105+
for (UiNodePtr uiNode : _graphNodes)
21062106
{
2107-
if (node->getNode())
2107+
if (uiNode->getNode())
21082108
{
2109-
for (mx::InputPtr input : node->getNode()->getActiveInputs())
2109+
for (mx::InputPtr input : uiNode->getNode()->getActiveInputs())
21102110
{
21112111
if (input->getInterfaceInput())
21122112
{
@@ -2547,7 +2547,7 @@ void Graph::addLink(ed::PinId startPinId, ed::PinId endPinId)
25472547
return;
25482548
}
25492549

2550-
// Perform type check
2550+
// Perform type check
25512551
bool typesMatch = (outputPin->_type == inputPin->_type);
25522552
if (!typesMatch)
25532553
{
@@ -3093,7 +3093,7 @@ void Graph::loadGraphFromFile(bool prompt)
30933093
_fileDialog.open();
30943094
}
30953095
else
3096-
{
3096+
{
30973097
_graphDoc = loadDocument(_materialFilename);
30983098

30993099
// Rebuild the UI
@@ -3104,7 +3104,7 @@ void Graph::loadGraphFromFile(bool prompt)
31043104

31053105
_renderer->setDocument(_graphDoc);
31063106
_renderer->updateMaterials(nullptr);
3107-
}
3107+
}
31083108
}
31093109

31103110
void Graph::saveGraphToFile()
@@ -3241,22 +3241,22 @@ void Graph::graphButtons()
32413241

32423242
// Create two windows using splitter
32433243
float paneWidth = (leftPaneWidth - 2.0f);
3244-
3244+
32453245
float aspectRatio = _renderer->getPixelRatio();
32463246
ImVec2 screenSize = ImVec2(paneWidth, paneWidth / aspectRatio);
32473247

32483248
ImVec2 mousePos = ImGui::GetMousePos();
32493249
ImVec2 tempWindowPos = ImGui::GetCursorPos();
32503250
bool cursorInRenderView = mousePos.x > tempWindowPos.x && mousePos.x < (tempWindowPos.x + screenSize.x) &&
32513251
mousePos.y > tempWindowPos.y && mousePos.y < (tempWindowPos.y + screenSize.y);
3252-
3252+
32533253
ImGuiWindowFlags windowFlags = 0;
32543254

32553255
if (cursorInRenderView)
32563256
{
32573257
windowFlags |= ImGuiWindowFlags_NoScrollWithMouse;
32583258
}
3259-
3259+
32603260
ImGui::BeginChild("Selection", ImVec2(paneWidth, 0), false, windowFlags);
32613261
ImVec2 windowPos = ImGui::GetWindowPos();
32623262

@@ -3306,16 +3306,16 @@ void Graph::propertyEditor()
33063306
std::string name = _currUiNode->getNode()->getParent()->createValidChildName(temp);
33073307

33083308
std::vector<UiNodePtr> downstreamNodes = _currUiNode->getOutputConnections();
3309-
for (UiNodePtr nodes : downstreamNodes)
3309+
for (UiNodePtr uiNode : downstreamNodes)
33103310
{
3311-
if (nodes->getInput() == nullptr)
3311+
if (!uiNode->getInput() && uiNode->getNode())
33123312
{
3313-
for (mx::InputPtr input : nodes->getNode()->getActiveInputs())
3313+
for (mx::InputPtr input : uiNode->getNode()->getActiveInputs())
33143314
{
33153315
if (input->getConnectedNode() == _currUiNode->getNode())
33163316
{
33173317
_currUiNode->getNode()->setName(name);
3318-
nodes->getNode()->setConnectedNode(input->getName(), _currUiNode->getNode());
3318+
uiNode->getNode()->setConnectedNode(input->getName(), _currUiNode->getNode());
33193319
}
33203320
}
33213321
}
@@ -3330,13 +3330,13 @@ void Graph::propertyEditor()
33303330
{
33313331
std::string name = _currUiNode->getInput()->getParent()->createValidChildName(temp);
33323332
std::vector<UiNodePtr> downstreamNodes = _currUiNode->getOutputConnections();
3333-
for (UiNodePtr nodes : downstreamNodes)
3333+
for (UiNodePtr uiNode : downstreamNodes)
33343334
{
3335-
if (nodes->getInput() == nullptr)
3335+
if (uiNode->getInput() == nullptr)
33363336
{
3337-
if (nodes->getNode())
3337+
if (uiNode->getNode())
33383338
{
3339-
for (mx::InputPtr input : nodes->getNode()->getActiveInputs())
3339+
for (mx::InputPtr input : uiNode->getNode()->getActiveInputs())
33403340
{
33413341
if (input->getInterfaceInput() == _currUiNode->getInput())
33423342
{
@@ -3349,7 +3349,7 @@ void Graph::propertyEditor()
33493349
}
33503350
else
33513351
{
3352-
nodes->getOutput()->setConnectedNode(_currUiNode->getNode());
3352+
uiNode->getOutput()->setConnectedNode(_currUiNode->getNode());
33533353
}
33543354
}
33553355
}
@@ -3726,7 +3726,6 @@ void Graph::addNodePopup(bool cursor)
37263726
}
37273727
}
37283728

3729-
37303729
ImGui::EndMenu();
37313730
}
37323731
}
@@ -3894,7 +3893,6 @@ void Graph::handleRenderViewInputs()
38943893
{
38953894
_renderer->setScrollEvent(scrollAmt);
38963895
}
3897-
38983896
}
38993897

39003898
void Graph::drawGraph(ImVec2 mousePos)

0 commit comments

Comments
 (0)