diff --git a/src/app/cmd.h b/src/app/cmd.h index 4a6fc8f95..575226d43 100644 --- a/src/app/cmd.h +++ b/src/app/cmd.h @@ -20,6 +20,7 @@ #define APP_CMD_H_INCLUDED #pragma once +#include "base/disable_copying.h" #include "doc/sprite_position.h" #include "undo/undo_command.h" @@ -55,6 +56,8 @@ namespace app { enum class State { NotExecuted, Executed, Undone, Redone }; State m_state; #endif + + DISABLE_COPYING(Cmd); }; } // namespace app diff --git a/src/app/cmd/add_palette.h b/src/app/cmd/add_palette.h index c3c710471..ab9ee85cf 100644 --- a/src/app/cmd/add_palette.h +++ b/src/app/cmd/add_palette.h @@ -51,7 +51,6 @@ namespace cmd { } private: - frame_t m_frame; std::stringstream m_stream; }; diff --git a/src/app/cmd/copy_frame.h b/src/app/cmd/copy_frame.h index 54716af2c..83941c9c9 100644 --- a/src/app/cmd/copy_frame.h +++ b/src/app/cmd/copy_frame.h @@ -43,7 +43,6 @@ namespace cmd { private: frame_t m_fromFrame; frame_t m_newFrame; - bool m_firstTime; }; } // namespace cmd diff --git a/src/app/cmd/copy_region.cpp b/src/app/cmd/copy_region.cpp index 812e5c108..8c8d4ae2c 100644 --- a/src/app/cmd/copy_region.cpp +++ b/src/app/cmd/copy_region.cpp @@ -89,7 +89,9 @@ void CopyRegion::swap() } } - std::swap(m_stream, tmp); + // TODO use m_stream.swap(tmp) when clang and gcc support it + m_stream.str(tmp.str()); + m_stream.clear(); } } // namespace cmd diff --git a/src/app/cmd/object_io.h b/src/app/cmd/object_io.h index 4806606ec..8ad3f57a2 100644 --- a/src/app/cmd/object_io.h +++ b/src/app/cmd/object_io.h @@ -22,6 +22,7 @@ #include "base/serialization.h" #include "base/unique_ptr.h" +#include "doc/object_id.h" #include "doc/subobjects_io.h" namespace doc { diff --git a/src/app/cmd/replace_image.h b/src/app/cmd/replace_image.h index 0fcb8fe76..b62e45e01 100644 --- a/src/app/cmd/replace_image.h +++ b/src/app/cmd/replace_image.h @@ -45,13 +45,13 @@ namespace cmd { } private: + ObjectId m_oldImageId; + ObjectId m_newImageId; + // Reference used only to keep the copy of the new image from the // ReplaceImage() ctor until the ReplaceImage::onExecute() call. // Then the reference is not used anymore. ImageRef m_newImage; - - ObjectId m_oldImageId; - ObjectId m_newImageId; ImageRef m_copy; }; diff --git a/src/app/cmd/set_cel_frame.h b/src/app/cmd/set_cel_frame.h index a479b2a7d..5317a2b39 100644 --- a/src/app/cmd/set_cel_frame.h +++ b/src/app/cmd/set_cel_frame.h @@ -17,7 +17,7 @@ */ #ifndef APP_CMD_SET_CEL_FRAME_H_INCLUDED -#define APP_CMD_SET_CEL_FRAME_CEL_H_INCLUDED +#define APP_CMD_SET_CEL_FRAME_H_INCLUDED #pragma once #include "app/cmd.h" diff --git a/src/app/commands/cmd_mask_content.cpp b/src/app/commands/cmd_mask_content.cpp index dd58400c5..a73fbb796 100644 --- a/src/app/commands/cmd_mask_content.cpp +++ b/src/app/commands/cmd_mask_content.cpp @@ -65,8 +65,6 @@ void MaskContentCommand::onExecute(Context* context) { ContextWriter writer(context); Document* document(writer.document()); - Sprite* sprite(writer.sprite()); - Layer* layer = writer.layer(); Cel* cel = writer.cel(); // Get current cel (can be NULL) if (!cel) return; diff --git a/src/app/commands/cmd_preview.cpp b/src/app/commands/cmd_preview.cpp index cba217571..0bfda7931 100644 --- a/src/app/commands/cmd_preview.cpp +++ b/src/app/commands/cmd_preview.cpp @@ -61,10 +61,10 @@ public: , m_doc(editor->document()) , m_sprite(editor->sprite()) , m_pal(m_sprite->palette(editor->frame())) + , m_zoom(editor->zoom()) , m_index_bg_color(-1) , m_doublebuf(Image::create(IMAGE_RGB, ui::display_w(), ui::display_h())) - , m_doublesur(she::instance()->createRgbaSurface(ui::display_w(), ui::display_h())) - , m_zoom(editor->zoom()) { + , m_doublesur(she::instance()->createRgbaSurface(ui::display_w(), ui::display_h())) { // Do not use DocumentWriter (do not lock the document) because we // will call other sub-commands (e.g. previous frame, next frame, // etc.). diff --git a/src/app/document_range_ops.cpp b/src/app/document_range_ops.cpp index 974ad6232..345722278 100644 --- a/src/app/document_range_ops.cpp +++ b/src/app/document_range_ops.cpp @@ -40,6 +40,12 @@ static DocumentRange drop_range_op( Document* doc, Op op, const DocumentRange& from, DocumentRangePlace place, const DocumentRange& to) { + if (place != kDocumentRangeBefore && + place != kDocumentRangeAfter) { + ASSERT(false); + throw std::invalid_argument("Invalid 'place' argument"); + } + Sprite* sprite = doc->sprite(); // Check noop/trivial/do nothing cases, i.e., move a range to the same place. @@ -83,6 +89,9 @@ static DocumentRange drop_range_op( switch (op) { case Move: undoLabel = "Move Range"; break; case Copy: undoLabel = "Copy Range"; break; + default: + ASSERT(false); + throw std::invalid_argument("Invalid 'op' argument"); } DocumentRange resultRange; diff --git a/src/app/transaction.cpp b/src/app/transaction.cpp index 482f2843f..a8c108cf3 100644 --- a/src/app/transaction.cpp +++ b/src/app/transaction.cpp @@ -34,7 +34,6 @@ using namespace doc; Transaction::Transaction(Context* ctx, const std::string& label, Modification modification) : m_ctx(ctx) - , m_modification(modification) , m_cmds(NULL) { DocumentLocation location = m_ctx->activeLocation(); diff --git a/src/app/transaction.h b/src/app/transaction.h index 7e645ec8a..75bcaca8f 100644 --- a/src/app/transaction.h +++ b/src/app/transaction.h @@ -73,7 +73,6 @@ namespace app { Context* m_ctx; DocumentUndo* m_undo; CmdTransaction* m_cmds; - Modification m_modification; }; } // namespace app diff --git a/src/doc/object.cpp b/src/doc/object.cpp index 7bd44dc7c..4466dbe81 100644 --- a/src/doc/object.cpp +++ b/src/doc/object.cpp @@ -13,13 +13,14 @@ #include "base/mutex.h" #include "base/scoped_lock.h" -#include +#include namespace doc { static base::mutex mutex; static ObjectId newId = 0; -static std::unordered_map objects; +// TODO Profile this and see if an unordered_map works best. +static std::map objects; Object::Object(ObjectType type) : m_type(type) diff --git a/src/render/render.cpp b/src/render/render.cpp index 60cf23f7e..511b6b0cb 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -415,10 +415,6 @@ void Render::renderLayer( if (!scaled_func) return; - const LayerImage* background = m_sprite->backgroundLayer(); - bool need_checked_bg = (background != NULL ? !background->isVisible(): true); - color_t bg_color = 0; - m_globalOpacity = 255; renderLayer(layer, dstImage, area, frame, Zoom(1, 1), scaled_func, diff --git a/src/ui/popup_window.cpp b/src/ui/popup_window.cpp index 949f21308..8c6c7fed3 100644 --- a/src/ui/popup_window.cpp +++ b/src/ui/popup_window.cpp @@ -187,6 +187,23 @@ void PopupWindow::onInitTheme(InitThemeEvent& ev) this->border_width.b = 3 * guiscale(); } +void PopupWindow::onHitTest(HitTestEvent& ev) +{ + Widget* picked = getManager()->pick(ev.getPoint()); + if (picked) { + WidgetType type = picked->getType(); + if ((type == kWindowWidget && picked == this) || + type == kBoxWidget || + type == kLabelWidget || + type == kGridWidget || + type == kSeparatorWidget) { + ev.setHit(HitTestCaption); + return; + } + } + Window::onHitTest(ev); +} + void PopupWindow::startFilteringMessages() { if (!m_filtering) { diff --git a/src/ui/popup_window.h b/src/ui/popup_window.h index 4bf139416..ee0a5d256 100644 --- a/src/ui/popup_window.h +++ b/src/ui/popup_window.h @@ -34,6 +34,7 @@ namespace ui { void onPreferredSize(PreferredSizeEvent& ev) override; void onPaint(PaintEvent& ev) override; void onInitTheme(InitThemeEvent& ev) override; + void onHitTest(HitTestEvent& ev) override; private: void startFilteringMessages();