[aseprite] 40/250: Fix strange scenarios/crashes using NewBrushCommand on multiple editors
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit c674c474f625d51a21ed01ef47e5c0603f061608
Author: David Capello <davidcapello at gmail.com>
Date: Tue Sep 15 12:09:50 2015 -0300
Fix strange scenarios/crashes using NewBrushCommand on multiple editors
We cannot use current_editor in SelectBoxDelegate implementations.
For example: NewBrushCommand cannot use the current_editor in
NewBrushCommand::onQuickboxEnd() because multiple editors can be in
SelectBoxState, and it looks like we can select the brush box in
a non-current editor if it's the first click to set that editor
as the current one.
---
src/app/commands/cmd_new_brush.cpp | 24 ++++++++++++------------
src/app/ui/editor/select_box_state.cpp | 4 ++--
src/app/ui/editor/select_box_state.h | 4 ++--
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/app/commands/cmd_new_brush.cpp b/src/app/commands/cmd_new_brush.cpp
index 21c685f..4f1811e 100644
--- a/src/app/commands/cmd_new_brush.cpp
+++ b/src/app/commands/cmd_new_brush.cpp
@@ -43,15 +43,15 @@ protected:
void onExecute(Context* context) override;
// SelectBoxDelegate impl
- void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) override;
- void onQuickboxCancel() override;
+ void onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons) override;
+ void onQuickboxCancel(Editor* editor) override;
std::string onGetContextBarHelp() override {
return "Select brush bounds | Right-click to cut";
}
private:
- void createBrush(const Mask* mask);
+ void createBrush(const Site& site, const Mask* mask);
void selectPencilTool();
};
@@ -92,7 +92,8 @@ void NewBrushCommand::onExecute(Context* context)
}
// Create a brush from the active selection
else {
- createBrush(context->activeDocument()->mask());
+ createBrush(context->activeSite(),
+ context->activeDocument()->mask());
selectPencilTool();
// Deselect mask
@@ -102,11 +103,11 @@ void NewBrushCommand::onExecute(Context* context)
}
}
-void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons)
+void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons)
{
Mask mask;
mask.replace(rect);
- createBrush(&mask);
+ createBrush(editor->getSite(), &mask);
selectPencilTool();
// If the right-button was used, we clear the selected area.
@@ -128,18 +129,17 @@ void NewBrushCommand::onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons butt
App::instance()->getMainWindow()->getContextBar()
->updateForCurrentTool();
- current_editor->backToPreviousState();
+ editor->backToPreviousState();
}
-void NewBrushCommand::onQuickboxCancel()
+void NewBrushCommand::onQuickboxCancel(Editor* editor)
{
- current_editor->backToPreviousState();
+ editor->backToPreviousState();
}
-void NewBrushCommand::createBrush(const Mask* mask)
+void NewBrushCommand::createBrush(const Site& site, const Mask* mask)
{
- doc::ImageRef image(new_image_from_mask(
- UIContext::instance()->activeSite(), mask));
+ doc::ImageRef image(new_image_from_mask(site, mask));
if (!image)
return;
diff --git a/src/app/ui/editor/select_box_state.cpp b/src/app/ui/editor/select_box_state.cpp
index 96ad848..2865683 100644
--- a/src/app/ui/editor/select_box_state.cpp
+++ b/src/app/ui/editor/select_box_state.cpp
@@ -110,9 +110,9 @@ bool SelectBoxState::onMouseUp(Editor* editor, MouseMessage* msg)
if (m_delegate) {
if (m_selectingButtons == msg->buttons())
- m_delegate->onQuickboxEnd(getBoxBounds(), msg->buttons());
+ m_delegate->onQuickboxEnd(editor, getBoxBounds(), msg->buttons());
else
- m_delegate->onQuickboxCancel();
+ m_delegate->onQuickboxCancel(editor);
}
}
diff --git a/src/app/ui/editor/select_box_state.h b/src/app/ui/editor/select_box_state.h
index a7a27f3..c632dd4 100644
--- a/src/app/ui/editor/select_box_state.h
+++ b/src/app/ui/editor/select_box_state.h
@@ -29,8 +29,8 @@ namespace app {
// Called only in QUICKBOX mode, when the user released the mouse
// button.
- virtual void onQuickboxEnd(const gfx::Rect& rect, ui::MouseButtons buttons) { }
- virtual void onQuickboxCancel() { }
+ virtual void onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::MouseButtons buttons) { }
+ virtual void onQuickboxCancel(Editor* editor) { }
// Help text to be shown in the ContextBar
virtual std::string onGetContextBarHelp() { return ""; }
--
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