Utility/Icon: Make Icon a RefCounted object
This commit is contained in:
@@ -16,30 +16,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
Icon::Icon() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool Icon::Create(const Image& icon)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_impl = new IconImpl;
|
||||
if (!m_impl->Create(icon))
|
||||
std::unique_ptr<IconImpl> impl(new IconImpl);
|
||||
if (!impl->Create(icon))
|
||||
{
|
||||
NazaraError("Failed to create icon implementation");
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
m_impl = impl.release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,9 +42,4 @@ namespace Nz
|
||||
m_impl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Icon::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,23 +408,13 @@ namespace Nz
|
||||
m_impl->SetFocus();
|
||||
}
|
||||
|
||||
void Window::SetIcon(const Icon& icon)
|
||||
void Window::SetIcon(IconRef icon)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!m_impl)
|
||||
{
|
||||
NazaraError("Window not created");
|
||||
return;
|
||||
}
|
||||
NazaraAssert(m_impl, "Window not created");
|
||||
NazaraAssert(icon && icon.IsValid(), "Invalid icon");
|
||||
|
||||
if (!icon.IsValid())
|
||||
{
|
||||
NazaraError("Icon is not valid");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_impl->SetIcon(icon);
|
||||
m_icon = std::move(icon);
|
||||
m_impl->SetIcon(*m_icon);
|
||||
}
|
||||
|
||||
void Window::SetMaximumSize(const Vector2i& maxSize)
|
||||
|
||||
Reference in New Issue
Block a user