Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Deletion of Node in the MaterialEdit leads to crash #736 #742

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions modules/editor/grapheditor/editor/graph/graphnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
#include <QMetaProperty>

#include <editor/assetconverter.h>
#include "graphwidgets/nodewidget.h"

Q_DECLARE_METATYPE(Vector2)
Q_DECLARE_METATYPE(Vector3)
Q_DECLARE_METATYPE(Vector4)

GraphNode::GraphNode() :
m_userData(nullptr),
m_nodeWidget(nullptr),
m_graph(nullptr) {

}

GraphNode::~GraphNode() {
delete m_nodeWidget;
}

AbstractNodeGraph *GraphNode::graph() const {
return m_graph;
}
Expand Down Expand Up @@ -63,11 +68,11 @@ void GraphNode::setPosition(const Vector2 &position) {
m_pos = position;
}

void *GraphNode::widget() const {
return m_userData;
NodeWidget *GraphNode::widget() const {
return m_nodeWidget;
}
void GraphNode::setWidget(void *widget) {
m_userData = widget;
void GraphNode::setWidget(NodeWidget *widget) {
m_nodeWidget = widget;
}

bool GraphNode::isState() const {
Expand Down
8 changes: 5 additions & 3 deletions modules/editor/grapheditor/editor/graph/graphnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class AbstractNodeGraph;
class GraphNode;
class NodeWidget;

class NODEGRAPH_EXPORT NodePort {
public:
Expand Down Expand Up @@ -60,6 +61,7 @@ class NODEGRAPH_EXPORT GraphNode : public QObject {
Q_OBJECT
public:
GraphNode();
~GraphNode();

AbstractNodeGraph *graph() const;
void setGraph(AbstractNodeGraph *graph);
Expand All @@ -80,8 +82,8 @@ class NODEGRAPH_EXPORT GraphNode : public QObject {

void setPosition(const Vector2 &position);

void *widget() const;
void setWidget(void *widget);
NodeWidget *widget() const;
void setWidget(NodeWidget *widget);

virtual bool isState() const;

Expand All @@ -100,7 +102,7 @@ class NODEGRAPH_EXPORT GraphNode : public QObject {

Vector2 m_pos;

void *m_userData;
NodeWidget *m_nodeWidget;

AbstractNodeGraph *m_graph;

Expand Down
Loading