refactor: deskflow/Clipboard, do not assert instead handle the cases where we would have asserted to fail safely
This commit is contained in:
@ -25,7 +25,8 @@ Clipboard::~Clipboard()
|
||||
|
||||
bool Clipboard::empty()
|
||||
{
|
||||
assert(m_open);
|
||||
if (!m_open)
|
||||
return false;
|
||||
|
||||
// clear all data
|
||||
for (int32_t index = 0; index < kNumFormats; ++index) {
|
||||
@ -44,8 +45,8 @@ bool Clipboard::empty()
|
||||
|
||||
void Clipboard::add(EFormat format, const std::string &data)
|
||||
{
|
||||
assert(m_open);
|
||||
assert(m_owner);
|
||||
if (!m_open || !m_owner)
|
||||
return;
|
||||
|
||||
m_data[format] = data;
|
||||
m_added[format] = true;
|
||||
@ -53,8 +54,8 @@ void Clipboard::add(EFormat format, const std::string &data)
|
||||
|
||||
bool Clipboard::open(Time time) const
|
||||
{
|
||||
assert(!m_open);
|
||||
|
||||
if (m_open)
|
||||
return true;
|
||||
m_open = true;
|
||||
m_time = time;
|
||||
|
||||
@ -63,8 +64,6 @@ bool Clipboard::open(Time time) const
|
||||
|
||||
void Clipboard::close() const
|
||||
{
|
||||
assert(m_open);
|
||||
|
||||
m_open = false;
|
||||
}
|
||||
|
||||
@ -75,13 +74,15 @@ Clipboard::Time Clipboard::getTime() const
|
||||
|
||||
bool Clipboard::has(EFormat format) const
|
||||
{
|
||||
assert(m_open);
|
||||
if (!m_open)
|
||||
return false;
|
||||
return m_added[format];
|
||||
}
|
||||
|
||||
std::string Clipboard::get(EFormat format) const
|
||||
{
|
||||
assert(m_open);
|
||||
if (!m_open)
|
||||
return "";
|
||||
return m_data[format];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user