Replace unique_ptr w/std::optional for optional values in doc::Brush

This commit is contained in:
David Capello 2022-11-03 08:26:10 -03:00
parent d029efbcc0
commit 66496bdcd2
2 changed files with 5 additions and 4 deletions

View File

@ -249,10 +249,10 @@ void Brush::setImageColor(ImageColor imageColor, color_t color)
switch (imageColor) {
case ImageColor::MainColor:
m_mainColor.reset(new color_t(color));
m_mainColor = color_t(color);
break;
case ImageColor::BackgroundColor:
m_bgColor.reset(new color_t(color));
m_bgColor = color_t(color);
break;
}

View File

@ -17,6 +17,7 @@
#include "gfx/rect.h"
#include <memory>
#include <optional>
#include <vector>
namespace doc {
@ -97,8 +98,8 @@ namespace doc {
// Extra data used for setImageColor()
ImageRef m_backupImage; // Backup image to avoid losing original brush colors/pattern
std::unique_ptr<color_t> m_mainColor; // Main image brush color (nullptr if it wasn't specified)
std::unique_ptr<color_t> m_bgColor; // Background color (nullptr if it wasn't specified)
std::optional<color_t> m_mainColor; // Main image brush color
std::optional<color_t> m_bgColor; // Background color
};
typedef std::shared_ptr<Brush> BrushRef;