From c7233c1c191453604afa2e6f3972dc1360085d34 Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Sun, 14 Apr 2024 01:11:30 +0200 Subject: [PATCH] Clean up some code --- core_lib/src/interface/editor.cpp | 17 ++++++----------- core_lib/src/util/pencilerror.cpp | 2 -- core_lib/src/util/pencilerror.h | 8 ++++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index 5210c0ba5f..b997168995 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -17,12 +17,9 @@ GNU General Public License for more details. #include "editor.h" -#include -#include #include #include #include -#include #include #include "object.h" @@ -1218,7 +1215,7 @@ KeyFrame* Editor::addNewKey() return addKeyFrame(layers()->currentLayerIndex(), currentFrame()); } -KeyFrame* Editor::addKeyFrame(int layerNumber, int frameIndex) +KeyFrame* Editor::addKeyFrame(const int layerNumber, int frameIndex) { Layer* layer = mObject->getLayer(layerNumber); Q_ASSERT(layer); @@ -1244,13 +1241,11 @@ KeyFrame* Editor::addKeyFrame(int layerNumber, int frameIndex) } } - bool ok = layer->addNewKeyFrameAt(frameIndex); - if (ok) - { - scrubTo(frameIndex); // currentFrameChanged() emit inside. - emit frameModified(frameIndex); - layers()->notifyAnimationLengthChanged(); - } + const bool ok = layer->addNewKeyFrameAt(frameIndex); + Q_ASSERT(ok); // We already ensured that there is no keyframe at frameIndex, so this should always succeed + scrubTo(frameIndex); // currentFrameChanged() emit inside. + emit frameModified(frameIndex); + layers()->notifyAnimationLengthChanged(); return layer->getKeyFrameAt(frameIndex); } diff --git a/core_lib/src/util/pencilerror.cpp b/core_lib/src/util/pencilerror.cpp index 9ba3046929..37198c48c3 100644 --- a/core_lib/src/util/pencilerror.cpp +++ b/core_lib/src/util/pencilerror.cpp @@ -17,9 +17,7 @@ GNU General Public License for more details. #include "pencilerror.h" #include -#include #include -#include "pencildef.h" DebugDetails::DebugDetails() { diff --git a/core_lib/src/util/pencilerror.h b/core_lib/src/util/pencilerror.h index e35870f6cd..ecd8848bf7 100644 --- a/core_lib/src/util/pencilerror.h +++ b/core_lib/src/util/pencilerror.h @@ -45,7 +45,7 @@ class Status OK = 0, SAFE, FAIL, - CANCELED, + CANCELED, FILE_NOT_FOUND, NOT_SUPPORTED, INVALID_ARGUMENT, @@ -65,8 +65,8 @@ class Status // Sound ERROR_LOAD_SOUND_FILE, - // Export - ERROR_FFMPEG_NOT_FOUND, + // Export + ERROR_FFMPEG_NOT_FOUND, // Layer ERROR_NEED_AT_LEAST_ONE_CAMERA_LAYER @@ -100,7 +100,7 @@ class Status #ifndef STATUS_CHECK #define STATUS_CHECK( x )\ - { Status st = (x); if (!st.ok()) { return st; } } + { Status st = (x); if (!st.ok()) { return st; } } #endif #ifndef STATUS_FAILED