Skip to content

Commit

Permalink
Editor: Animation state machine editor crashed #860
Browse files Browse the repository at this point in the history
  • Loading branch information
eprikazchikov committed Oct 28, 2024
1 parent becb5c4 commit 366727d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ void AbstractNodeGraph::load(const QString &path) {
save(path);
}
}

emit graphLoaded();
}

void AbstractNodeGraph::save(const QString &path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class NODEGRAPH_EXPORT AbstractNodeGraph : public QObject {

signals:
void graphUpdated();
void graphLoaded();

void messageReported(int node, const QString &text);

Expand Down
6 changes: 6 additions & 0 deletions modules/editor/grapheditor/editor/graph/graphcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ AbstractNodeGraph *GraphController::graph() {
void GraphController::setGraph(AbstractNodeGraph *graph) {
m_graph = graph;

m_focusedWidget = nullptr;
m_drag = false;

m_selectedItems.clear();
m_softSelectedItems.clear();

if(m_graph->rootNode()) {
setSelected({ m_graph->rootNode() });
emit m_view->itemsSelected(m_selectedItems);
Expand Down
6 changes: 6 additions & 0 deletions modules/editor/grapheditor/editor/graph/graphview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void GraphView::setGraph(AbstractNodeGraph *graph) {
static_cast<GraphController *>(m_controller)->setGraph(graph);

connect(graph, &AbstractNodeGraph::graphUpdated, this, &GraphView::onGraphUpdated);
connect(graph, &AbstractNodeGraph::graphLoaded, this, &GraphView::onGraphLoaded);

// Create menu
for(auto &it : graph->nodeList()) {
Expand Down Expand Up @@ -325,6 +326,11 @@ void GraphView::onGraphUpdated() {
composeLinks();
}

void GraphView::onGraphLoaded() {
GraphController *ctrl = static_cast<GraphController *>(m_controller);
ctrl->setGraph(ctrl->graph());
}

void GraphView::reselect() {
auto list = static_cast<GraphController *>(m_controller)->selectedItems();
emit itemsSelected(list);
Expand Down
2 changes: 2 additions & 0 deletions modules/editor/grapheditor/editor/graph/graphview.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ private slots:

void onGraphUpdated();

void onGraphLoaded();

void onDraw() override;

protected:
Expand Down

0 comments on commit 366727d

Please sign in to comment.