diff --git a/Engine/EffectInstance.cpp b/Engine/EffectInstance.cpp index 17e0281f64..1e1176a88d 100644 --- a/Engine/EffectInstance.cpp +++ b/Engine/EffectInstance.cpp @@ -2217,7 +2217,12 @@ EffectInstance::Implementation::tiledRenderingFunctor(const RectToRender & rectT #endif EffectTLSDataPtr tls = tlsData->getOrCreateTLSData(); - assert( !rectToRender.rect.isNull() ); + if ( rectToRender.rect.isNull() ) { + // should never happen, but crashes when loading + // https://github.com/NatronGitHub/Natron/files/4630686/maskissue.log + //assert(false); + return eRenderingFunctorRetOK; + } /* * renderMappedRectToRender is in the mapped mipmap level, i.e the expected mipmap level of the render action of the plug-in diff --git a/Gui/NodeGraph.cpp b/Gui/NodeGraph.cpp index a4054b8535..6a682e0353 100644 --- a/Gui/NodeGraph.cpp +++ b/Gui/NodeGraph.cpp @@ -176,7 +176,6 @@ NodeGraph::NodeGraph(Gui* gui, _imp->_bR->setPos( _imp->_bR->mapFromScene( QPointF(NATRON_SCENE_MAX, NATRON_SCENE_MIN) ) ); _imp->_bL->setPos( _imp->_bL->mapFromScene( QPointF(NATRON_SCENE_MIN, NATRON_SCENE_MIN) ) ); centerOn(0, 0); - setSceneRect(NATRON_SCENE_MIN, NATRON_SCENE_MIN, NATRON_SCENE_MAX, NATRON_SCENE_MAX); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); diff --git a/Gui/NodeGraph30.cpp b/Gui/NodeGraph30.cpp index 21d6ccd90a..a4be3141be 100644 --- a/Gui/NodeGraph30.cpp +++ b/Gui/NodeGraph30.cpp @@ -179,7 +179,6 @@ NodeGraph::wheelEventInternal(bool ctrlDown, _imp->_accumDelta += delta; if (std::abs(_imp->_accumDelta) > 60) { scaleFactor = pow( NATRON_WHEEL_ZOOM_PER_DELTA, _imp->_accumDelta ); - // setSceneRect(NATRON_SCENE_MIN,NATRON_SCENE_MIN,NATRON_SCENE_MAX,NATRON_SCENE_MAX); scale(scaleFactor, scaleFactor); _imp->_accumDelta = 0; } diff --git a/Gui/NodeGraph35.cpp b/Gui/NodeGraph35.cpp index 9ee8f7b521..5cdacc6c4e 100644 --- a/Gui/NodeGraph35.cpp +++ b/Gui/NodeGraph35.cpp @@ -484,14 +484,17 @@ NodeGraph::showMenu(const QPoint & pos) if (ret == findAction) { popFindDialog(); } else if (ret == duplicateAction) { - QRectF rect = visibleSceneRect(); - duplicateSelectedNodes( rect.center() ); + // Duplicate at mouse click position: + QPointF scenePos = mapToScene( mapFromGlobal(pos) ); + cloneSelectedNodes(scenePos); } else if (ret == cloneAction) { - QRectF rect = visibleSceneRect(); - cloneSelectedNodes( rect.center() ); + // Clone at mouse click position: + QPointF scenePos = mapToScene( mapFromGlobal(pos) ); + cloneSelectedNodes(scenePos); } else if (ret == pasteAction) { - QRectF rect = visibleSceneRect(); - pasteNodeClipBoards( rect.center() ); + // Paste at mouse click position: + QPointF scenePos = mapToScene( mapFromGlobal(pos) ); + cloneSelectedNodes(scenePos); } } // NodeGraph::showMenu diff --git a/Gui/NodeGraph40.cpp b/Gui/NodeGraph40.cpp index 475d85277e..f0b73ce8ca 100644 --- a/Gui/NodeGraph40.cpp +++ b/Gui/NodeGraph40.cpp @@ -189,7 +189,7 @@ NodeGraph::pasteNodeClipBoards(const QPointF& pos) return false; } - _imp->pasteNodesInternal(cb, pos, true, &newNodes); + _imp->pasteNodesInternal(cb, _imp->_root->mapFromScene(pos), true, &newNodes); return true; } @@ -197,7 +197,7 @@ NodeGraph::pasteNodeClipBoards(const QPointF& pos) bool NodeGraph::pasteNodeClipBoards() { - QPointF position = _imp->_root->mapFromScene( mapToScene( mapFromGlobal( QCursor::pos() ) ) ); + QPointF position = mapToScene( mapFromGlobal( QCursor::pos() ) ); return pasteNodeClipBoards(position); } @@ -215,13 +215,13 @@ NodeGraph::duplicateSelectedNodes(const QPointF& pos) NodeClipBoard tmpClipboard; _imp->copyNodesInternal(_imp->_selection, tmpClipboard); std::list > newNodes; - _imp->pasteNodesInternal(tmpClipboard, pos, true, &newNodes); + _imp->pasteNodesInternal(tmpClipboard, _imp->_root->mapFromScene(pos), true, &newNodes); } void NodeGraph::duplicateSelectedNodes() { - QPointF scenePos = _imp->_root->mapFromScene( mapToScene( mapFromGlobal( QCursor::pos() ) ) ); + QPointF scenePos = mapToScene( mapFromGlobal( QCursor::pos() ) ); duplicateSelectedNodes(scenePos); } @@ -337,7 +337,7 @@ NodeGraph::cloneSelectedNodes(const QPointF& scenePos) void NodeGraph::cloneSelectedNodes() { - QPointF scenePos = _imp->_root->mapFromScene( mapToScene( mapFromGlobal( QCursor::pos() ) ) ); + QPointF scenePos = mapToScene( mapFromGlobal( QCursor::pos() ) ); cloneSelectedNodes(scenePos); } // cloneSelectedNodes @@ -457,7 +457,10 @@ NodeGraph::centerOnAllNodes() } } } - QRectF bbox( xmin, ymin, (xmax - xmin), (ymax - ymin) ); + // Move the scene so that topleft of the viewing area is at 0,0, and avoid issues + // when topleft has negative coords. + moveRootInternal(-xmin, -ymin); + QRectF bbox( 0, 0, (xmax - xmin), (ymax - ymin) ); fitInView(bbox, Qt::KeepAspectRatio); double currentZoomFactor = transform().mapRect( QRectF(0, 0, 1, 1) ).width(); diff --git a/Gui/NodeGraphUndoRedo.cpp b/Gui/NodeGraphUndoRedo.cpp index 6c4f6b2bb4..9379d27db5 100644 --- a/Gui/NodeGraphUndoRedo.cpp +++ b/Gui/NodeGraphUndoRedo.cpp @@ -166,6 +166,7 @@ AddMultipleNodesCommand::undo() for (std::list::iterator it = viewersToRefresh.begin(); it != viewersToRefresh.end(); ++it) { (*it)->renderCurrentFrame(true); } + _graph->updateNavigator(); } void @@ -212,6 +213,7 @@ AddMultipleNodesCommand::redo() } _firstRedoCalled = true; + _graph->updateNavigator(); } RemoveMultipleNodesCommand::RemoveMultipleNodesCommand(NodeGraph* graph, @@ -246,6 +248,7 @@ RemoveMultipleNodesCommand::RemoveMultipleNodesCommand(NodeGraph* graph, } _nodes.push_back(n); } + setText( tr("Remove node(s)") ); } RemoveMultipleNodesCommand::~RemoveMultipleNodesCommand() @@ -258,7 +261,6 @@ RemoveMultipleNodesCommand::~RemoveMultipleNodesCommand() } } } - setText( tr("Remove node(s)") ); } void @@ -310,6 +312,7 @@ RemoveMultipleNodesCommand::undo() _isRedone = false; _graph->scene()->update(); + _graph->updateNavigator(); } // RemoveMultipleNodesCommand::undo void @@ -402,6 +405,7 @@ RemoveMultipleNodesCommand::redo() _graph->updateNavigator(); _graph->scene()->update(); + _graph->updateNavigator(); } // redo ConnectCommand::ConnectCommand(NodeGraph* graph,