diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index eff9102d..bcf3f73c 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -55,6 +55,7 @@ void CPasteNodesCommand::redo() CMemoryInStream In(rkNode.InstanceData.data(), rkNode.InstanceData.size(), IOUtil::eBigEndian); CScriptObject *pInstance = CScriptLoader::LoadInstance(In, pArea, mpLayer, pArea->Version(), true); pArea->AddInstanceToArea(pInstance); + mpLayer->AddInstance(pInstance); pInstance->SetPosition(rkNode.Position + mPastePoint); pInstance->SetRotation(rkNode.Rotation.ToEuler()); @@ -107,7 +108,9 @@ void CPasteNodesCommand::redo() CScriptObject *pReceiver = pLink->Receiver(); if (pSender) pSender->RemoveLink(eOutgoing, pLink); if (pReceiver) pReceiver->RemoveLink(eIncoming, pLink); + delete pLink; + iLink--; } } } diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 7c38f6a2..342b9068 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -227,6 +227,9 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea) Log::Write("Loaded level: World " + mpWorld->Source() + " / Area " + mpArea->Source() + " (" + TO_TSTRING(LevelName) + ")"); } + // Update paste action + OnClipboardDataModified(); + // Emit signals emit LayersModified(); } @@ -650,8 +653,9 @@ void CWorldEditor::GizmoModeChanged(CGizmo::EGizmoMode mode) // ************ PRIVATE SLOTS ************ void CWorldEditor::OnClipboardDataModified() { - const QMimeData *pkMimeData = qApp->clipboard()->mimeData(); - bool ValidMimeData = (qobject_cast(pkMimeData) != nullptr); + const QMimeData *pkClipboardMimeData = qApp->clipboard()->mimeData(); + const CNodeCopyMimeData *pkMimeData = qobject_cast(pkClipboardMimeData); + bool ValidMimeData = (pkMimeData && pkMimeData->Game() == CurrentGame()); ui->ActionPaste->setEnabled(ValidMimeData); }