From 62e5bb48676d0457383cd8e7a4ced0fefb9a2a38 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sun, 8 Mar 2026 15:48:09 -0700 Subject: [PATCH] Removed LoadCheckpoint. --- common/lc_model.cpp | 68 ++++----------------------------------------- common/lc_model.h | 3 -- 2 files changed, 6 insertions(+), 65 deletions(-) diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 2d4dcf6f..c99b6452 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1935,9 +1935,11 @@ void lcModel::RunActionSequence(const std::vector if (SelectionChanged) gMainWindow->UpdateSelectedObjects(true); - - UpdateAllViews(); + + gMainWindow->UpdateCurrentStep(); gMainWindow->UpdateTimeline(true, false); + + UpdateAllViews(); } void lcModel::BeginActionSequence() @@ -2051,64 +2053,6 @@ const lcModelHistoryEntry* lcModel::GetFirstUndoChange() const return nullptr; } -void lcModel::LoadCheckPoint(lcModelHistoryEntry* CheckPoint, bool Apply) -{ - if (!CheckPoint->ModelActions.empty()) - { - RunActionSequence(CheckPoint->ModelActions, Apply); - - return; - } - - lcPiecesLibrary* Library = lcGetPiecesLibrary(); - std::vector LoadedInfos; - - for (const std::unique_ptr& Piece : mPieces) - { - PieceInfo* Info = Piece->mPieceInfo; - Library->LoadPieceInfo(Info, true, true); - LoadedInfos.push_back(Info); - } - - // Remember the current step - const lcStep CurrentStep = mCurrentStep; - - // Remember the camera names - std::vector Views = lcView::GetModelViews(this); - std::vector CameraNames(Views.size()); - - for (size_t ViewIndex = 0; ViewIndex < Views.size(); ViewIndex++) - { - lcCamera* Camera = Views[ViewIndex]->GetCamera(); - - if (!Camera->IsSimple()) - CameraNames[ViewIndex] = Camera->GetName(); - } - - DeleteModel(); - - QBuffer Buffer(&CheckPoint->File); - Buffer.open(QIODevice::ReadOnly); - LoadLDraw(Buffer, lcGetActiveProject()); - - // Reset the current step - mCurrentStep = CurrentStep; - CalculateStep(CurrentStep); - - // Reset the cameras - for (size_t ViewIndex = 0; ViewIndex < Views.size() && ViewIndex < CameraNames.size(); ViewIndex++) - if (!CameraNames[ViewIndex].isEmpty()) - Views[ViewIndex]->SetCamera(CameraNames[ViewIndex]); - - gMainWindow->UpdateTimeline(true, false); - gMainWindow->UpdateCurrentStep(); - gMainWindow->UpdateSelectedObjects(true); - UpdateAllViews(); - - for (PieceInfo* Info : LoadedInfos) - Library->ReleasePieceInfo(Info); -} - void lcModel::SetActive(bool Active) { CalculateStep(Active ? mCurrentStep : LC_STEP_MAX); @@ -4827,7 +4771,7 @@ void lcModel::UndoAction() std::unique_ptr Undo = std::move(mUndoHistory.front()); - LoadCheckPoint(Undo.get(), false); + RunActionSequence(Undo->ModelActions, false); mUndoHistory.erase(mUndoHistory.begin()); mRedoHistory.insert(mRedoHistory.begin(), std::move(Undo)); @@ -4843,7 +4787,7 @@ void lcModel::RedoAction() std::unique_ptr Redo = std::move(mRedoHistory.front()); - LoadCheckPoint(Redo.get(), true); + RunActionSequence(Redo->ModelActions, true); mRedoHistory.erase(mRedoHistory.begin()); mUndoHistory.insert(mUndoHistory.begin(), std::move(Redo)); diff --git a/common/lc_model.h b/common/lc_model.h index 9a9948ee..6de134d1 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -112,7 +112,6 @@ public: struct lcModelHistoryEntry { std::vector> ModelActions; - QByteArray File; QString Description; }; @@ -413,8 +412,6 @@ protected: void RemoveFirstUndoIfUnchanged(); const lcModelHistoryEntry* GetFirstUndoChange() const; - void LoadCheckPoint(lcModelHistoryEntry* CheckPoint, bool Apply); - QString GetGroupName(const QString& Prefix); void RemoveEmptyGroups(); bool RemoveSelectedObjects();