This is an automated email from the git hooks/post-receive script. thansen pushed a commit to branch master in repository aseprite.
commit 84d8a7a4ec3e66b7c21bb5e3ab32ecf9c0018cf5 Author: David Capello <[email protected]> Date: Sat Apr 16 21:29:57 2016 -0300 Add SpriteWrap::commitImages() to commit changes to images This might be useful to use before we execute commands like Sprite.resize or Sprite.crop, which they need all images in the most updated state. --- src/app/script/image_wrap.cpp | 3 +++ src/app/script/sprite_class.cpp | 4 ++++ src/app/script/sprite_wrap.cpp | 16 ++++++++++++---- src/app/script/sprite_wrap.h | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/script/image_wrap.cpp b/src/app/script/image_wrap.cpp index 9b6828a..4e475c0 100644 --- a/src/app/script/image_wrap.cpp +++ b/src/app/script/image_wrap.cpp @@ -39,6 +39,9 @@ void ImageWrap::commit() m_backup.get(), m_modifiedRegion, 0, 0, true)); + + m_backup.reset(nullptr); + m_modifiedRegion.clear(); } void ImageWrap::modifyRegion(const gfx::Region& rgn) diff --git a/src/app/script/sprite_class.cpp b/src/app/script/sprite_class.cpp index e1151b2..07aff91 100644 --- a/src/app/script/sprite_class.cpp +++ b/src/app/script/sprite_class.cpp @@ -58,6 +58,8 @@ script::result_t Sprite_resize(script::ContextHandle handle) auto wrap = (SpriteWrap*)ctx.getThis(); if (wrap) { + wrap->commitImages(); + Document* doc = wrap->document(); DocumentApi api(doc, wrap->transaction()); api.setSpriteSize(doc->sprite(), w, h); @@ -76,6 +78,8 @@ script::result_t Sprite_crop(script::ContextHandle handle) auto wrap = (SpriteWrap*)ctx.getThis(); if (wrap) { + wrap->commitImages(); + Document* doc = wrap->document(); DocumentApi api(doc, wrap->transaction()); api.cropSprite(doc->sprite(), gfx::Rect(x, y, w, h)); diff --git a/src/app/script/sprite_wrap.cpp b/src/app/script/sprite_wrap.cpp index cfdbbef..b3caa02 100644 --- a/src/app/script/sprite_wrap.cpp +++ b/src/app/script/sprite_wrap.cpp @@ -51,8 +51,7 @@ Transaction& SpriteWrap::transaction() void SpriteWrap::commit() { - for (auto it : m_images) - it.second->commit(); + commitImages(); if (m_transaction) { m_transaction->commit(); @@ -61,6 +60,12 @@ void SpriteWrap::commit() } } +void SpriteWrap::commitImages() +{ + for (auto it : m_images) + it.second->commit(); +} + app::Document* SpriteWrap::document() { return m_doc; @@ -73,8 +78,11 @@ doc::Sprite* SpriteWrap::sprite() ImageWrap* SpriteWrap::activeImage() { - if (!m_view) - return nullptr; + if (!m_view) { + m_view = UIContext::instance()->getFirstDocumentView(m_doc); + if (!m_view) + return nullptr; + } doc::Site site; m_view->getSite(&site); diff --git a/src/app/script/sprite_wrap.h b/src/app/script/sprite_wrap.h index 5b4f05c..7085bcb 100644 --- a/src/app/script/sprite_wrap.h +++ b/src/app/script/sprite_wrap.h @@ -32,6 +32,7 @@ namespace app { ~SpriteWrap(); void commit(); + void commitImages(); Transaction& transaction(); app::Document* document(); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git _______________________________________________ Pkg-games-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

