diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 21:36:04 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-11 21:36:04 +0200 |
commit | c57cf9834b4fc40bd1556950b2e78573bb2159f8 (patch) | |
tree | b54f10f10c0dddf62e40e0a9beb4d86ea20e240f /LibGUI/GVariant.cpp | |
parent | 52152e171b42973a39f0d18064fe6cd5582dfd8f (diff) | |
download | serenity-c57cf9834b4fc40bd1556950b2e78573bb2159f8.zip |
LibGUI: Add GVariant copy constructor.
Diffstat (limited to 'LibGUI/GVariant.cpp')
-rw-r--r-- | LibGUI/GVariant.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/LibGUI/GVariant.cpp b/LibGUI/GVariant.cpp index ed308d0a02..0e9373aaba 100644 --- a/LibGUI/GVariant.cpp +++ b/LibGUI/GVariant.cpp @@ -9,16 +9,13 @@ GVariant::~GVariant() { switch (m_type) { case Type::String: - if (m_value.as_string) - m_value.as_string->release(); + AK::release_if_not_null(m_value.as_string); break; case Type::Bitmap: - if (m_value.as_bitmap) - m_value.as_bitmap->release(); + AK::release_if_not_null(m_value.as_bitmap); break; case Type::Icon: - if (m_value.as_icon) - m_value.as_icon->release(); + AK::release_if_not_null(m_value.as_icon); break; default: break; @@ -70,6 +67,39 @@ GVariant::GVariant(Color color) m_value.as_color = color.value(); } +GVariant::GVariant(const GVariant& other) + : m_type(other.m_type) +{ + switch (m_type) { + case Type::Bool: + m_value.as_bool = other.m_value.as_bool; + break; + case Type::Int: + m_value.as_int = other.m_value.as_int; + break; + case Type::Float: + m_value.as_float = other.m_value.as_float; + break; + case Type::String: + m_value.as_string = other.m_value.as_string; + AK::retain_if_not_null(m_value.as_bitmap); + break; + case Type::Bitmap: + m_value.as_bitmap = other.m_value.as_bitmap; + AK::retain_if_not_null(m_value.as_bitmap); + break; + case Type::Icon: + m_value.as_icon = other.m_value.as_icon; + AK::retain_if_not_null(m_value.as_icon); + break; + case Type::Color: + m_value.as_color = other.m_value.as_color; + break; + case Type::Invalid: + break; + } +} + bool GVariant::operator==(const GVariant& other) const { if (m_type != other.m_type) |