diff --git a/src/editor/action/mouse/mouse_action.cpp b/src/editor/action/mouse/mouse_action.cpp index 0d9c44bd312c..e1d63b8bf485 100644 --- a/src/editor/action/mouse/mouse_action.cpp +++ b/src/editor/action/mouse/mouse_action.cpp @@ -253,7 +253,8 @@ editor_action* brush_drag_mouse_action::drag_generic(editor_display& disp, int x const brush& brush_drag_mouse_action::get_brush() { assert(brush_); - return *brush_; + assert(*brush_); + return **brush_; } diff --git a/src/editor/action/mouse/mouse_action.hpp b/src/editor/action/mouse/mouse_action.hpp index 84b0b197edd5..71d1de61fdfd 100644 --- a/src/editor/action/mouse/mouse_action.hpp +++ b/src/editor/action/mouse/mouse_action.hpp @@ -165,7 +165,7 @@ class mouse_action class brush_drag_mouse_action : public mouse_action { public: - brush_drag_mouse_action(common_palette& palette, const brush* brush, const CKey& key) + brush_drag_mouse_action(common_palette& palette, const brush* const * const brush, const CKey& key) : mouse_action(palette, key) , previous_drag_hex_() , brush_(brush) @@ -235,12 +235,12 @@ class brush_drag_mouse_action : public mouse_action editor_action* drag_generic(editor_display& disp, int x, int y, bool& partial, editor_action* last_undo); /** - * Current brush handle. Currently pointer to brush with full constness. + * Current brush handle. Currently a pointer-to-pointer with full constness. * The mouse action does not modify the brush, does not modify the pointer * to the current brush, and we allow setting this pointr only once, hence * the three "consts". */ - const brush* const brush_; + const brush* const * const brush_; }; /** @@ -250,7 +250,7 @@ class mouse_action_paint : public brush_drag_mouse_action { public: mouse_action_paint( - const brush* brush, const CKey& key, terrain_palette& palette) + const brush* const * const brush, const CKey& key, terrain_palette& palette) : brush_drag_mouse_action(palette, brush, key) , terrain_palette_(palette) { diff --git a/src/editor/action/mouse/mouse_action_select.hpp b/src/editor/action/mouse/mouse_action_select.hpp index 2b686e9060a0..baab427ac53b 100644 --- a/src/editor/action/mouse/mouse_action_select.hpp +++ b/src/editor/action/mouse/mouse_action_select.hpp @@ -27,7 +27,7 @@ namespace editor { class mouse_action_select : public brush_drag_mouse_action { public: - mouse_action_select(const brush* brush, const CKey& key, empty_palette& palette) + mouse_action_select(const brush* const * const brush, const CKey& key, empty_palette& palette) : brush_drag_mouse_action(palette, brush, key) { } diff --git a/src/editor/toolkit/editor_toolkit.cpp b/src/editor/toolkit/editor_toolkit.cpp index 28b14e8c7dfa..fe13e993573d 100644 --- a/src/editor/toolkit/editor_toolkit.cpp +++ b/src/editor/toolkit/editor_toolkit.cpp @@ -31,7 +31,7 @@ editor_toolkit::editor_toolkit(editor_display& gui, const CKey& key, , palette_manager_() , mouse_action_(nullptr) // Will be set before this constructor ends. , mouse_actions_() - , brush_(nullptr) // Will be set before this constructor ends. + , brush_(nullptr) , brushes_() { init_brushes(game_config); @@ -62,11 +62,11 @@ void editor_toolkit::init_sidebar(const config& game_config) void editor_toolkit::init_mouse_actions(context_manager& cmanager) { mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_PAINT, - std::make_shared(brush_, key_, *palette_manager_->terrain_palette_.get())); + std::make_shared(&brush_, key_, *palette_manager_->terrain_palette_.get())); mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_FILL, std::make_shared(key_, *palette_manager_->terrain_palette_.get())); mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_SELECT, - std::make_shared(brush_, key_, *palette_manager_->empty_palette_.get())); + std::make_shared(&brush_, key_, *palette_manager_->empty_palette_.get())); mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION, std::make_shared(key_, *palette_manager_->location_palette_.get())); mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_LABEL,