[aseprite] 57/308: Fix crash on GotoNext/PreviousFrameWithSameTagCommands when there is no tag

Tobias Hansen thansen at moszumanska.debian.org
Tue Mar 8 02:44:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit f389a2ec23b9dbea90177b7af41a610734e9443e
Author: David Capello <davidcapello at gmail.com>
Date:   Sat Dec 5 15:42:12 2015 -0300

    Fix crash on GotoNext/PreviousFrameWithSameTagCommands when there is no tag
    
    Some other minor changes as avoid casting int <-> frame_t because now
    frame_t is a typedef (some time ago it was a class and those cast were
    necessary).
    
    Related to #887
---
 src/app/commands/cmd_goto_frame.cpp | 44 ++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/app/commands/cmd_goto_frame.cpp b/src/app/commands/cmd_goto_frame.cpp
index c7a4ca6..9f21079 100644
--- a/src/app/commands/cmd_goto_frame.cpp
+++ b/src/app/commands/cmd_goto_frame.cpp
@@ -53,7 +53,7 @@ public:
 
 protected:
   frame_t onGetFrame(Editor* editor) override {
-    return frame_t(0);
+    return 0;
   }
 };
 
@@ -67,11 +67,9 @@ public:
 protected:
   frame_t onGetFrame(Editor* editor) override {
     frame_t frame = editor->frame();
+    frame_t last = editor->sprite()->lastFrame();
 
-    if (frame > frame_t(0))
-      return frame-1;
-    else
-      return editor->sprite()->lastFrame();
+    return (frame > 0 ? frame-1: last);
   }
 };
 
@@ -84,10 +82,9 @@ public:
 protected:
   frame_t onGetFrame(Editor* editor) override {
     frame_t frame = editor->frame();
-    if (frame < editor->sprite()->lastFrame())
-      return frame+1;
-    else
-      return frame_t(0);
+    frame_t last = editor->sprite()->lastFrame();
+
+    return (frame < last ? frame+1: 0);
   }
 };
 
@@ -99,15 +96,12 @@ public:
 
 protected:
   frame_t onGetFrame(Editor* editor) override {
-    Sprite* sprite = editor->sprite();
-    frame_t currentFrame = editor->frame();
-    FrameTag* tag = get_animation_tag(sprite, currentFrame);
-    frame_t frameToGo = currentFrame + frame_t(1);
-
-    if (frameToGo > tag->toFrame())
-      frameToGo = tag->fromFrame();
+    frame_t frame = editor->frame();
+    FrameTag* tag = get_animation_tag(editor->sprite(), frame);
+    frame_t first = (tag ? tag->fromFrame(): 0);
+    frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
 
-    return frameToGo;
+    return (frame < last ? frame+1: first);
   }
 };
 
@@ -119,15 +113,12 @@ public:
 
 protected:
   frame_t onGetFrame(Editor* editor) override {
-    Sprite* sprite = editor->sprite();
-    frame_t currentFrame = editor->frame();
-    FrameTag* tag = get_animation_tag(sprite, currentFrame);
-    frame_t frameToGo = currentFrame - frame_t(1);
-
-    if (frameToGo < tag->fromFrame())
-      frameToGo = tag->toFrame();
+    frame_t frame = editor->frame();
+    FrameTag* tag = get_animation_tag(editor->sprite(), frame);
+    frame_t first = (tag ? tag->fromFrame(): 0);
+    frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());
 
-    return frameToGo;
+    return (frame > first ? frame-1: last);
   }
 };
 
@@ -151,8 +142,7 @@ public:
   Command* clone() const override { return new GotoFrameCommand(*this); }
 
 protected:
-  void onLoadParams(const Params& params) override
-  {
+  void onLoadParams(const Params& params) override {
     std::string frame = params.get("frame");
     if (!frame.empty()) m_frame = strtol(frame.c_str(), NULL, 10);
     else m_frame = 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list