Prevented open clipboard twice #4815

This commit is contained in:
Jerry 2015-07-06 13:00:28 -07:00
parent 6e74655e78
commit 23739f8484
2 changed files with 51 additions and 46 deletions

View File

@ -314,7 +314,10 @@ XWindowsClipboard::add(EFormat format, const String& data)
bool
XWindowsClipboard::open(Time time) const
{
assert(!m_open);
if (m_open) {
return false;
LOG((CLOG_DEBUG "failed to open clipboard: already opened"));
}
LOG((CLOG_DEBUG "open clipboard %d", m_id));

View File

@ -30,8 +30,8 @@ IClipboard::unmarshall(IClipboard* clipboard, const String& data, Time time)
const char* index = data.data();
if (clipboard->open(time)) {
// clear existing data
clipboard->open(time);
clipboard->empty();
// read the number of formats
@ -60,6 +60,7 @@ IClipboard::unmarshall(IClipboard* clipboard, const String& data, Time time)
// done
clipboard->close();
}
}
String
@ -72,7 +73,7 @@ IClipboard::marshall(const IClipboard* clipboard)
std::vector<String> formatData;
formatData.resize(IClipboard::kNumFormats);
// FIXME -- use current time
clipboard->open(0);
if (clipboard->open(0)) {
// compute size of marshalled data
UInt32 size = 4;
@ -99,6 +100,7 @@ IClipboard::marshall(const IClipboard* clipboard)
}
}
clipboard->close();
}
return data;
}