cached_formats_ = read_clipboard()->formats();
// Qt times out after 5 seconds if it does not recieve a response.
cached_formats_ = read_clipboard()->formats();
// Qt times out after 5 seconds if it does not recieve a response.
connect(qApp->clipboard(), SIGNAL(dataChanged()),
this, SLOT(on_dataChanged()));
// initialize clipboard status.
connect(qApp->clipboard(), SIGNAL(dataChanged()),
this, SLOT(on_dataChanged()));
// initialize clipboard status.
// We don't convert encodings here since the encoding of the
// clipboard contents is specified in the data itself
if (cache_.hasFormat(lyxMimeType())) {
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(lyxMimeType());
string const s(ar.data(), ar.count());
// We don't convert encodings here since the encoding of the
// clipboard contents is specified in the data itself
if (cache_.hasFormat(lyxMimeType())) {
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(lyxMimeType());
string const s(ar.data(), ar.count());
case WmfGraphicsType: mime = wmfMimeType(); break;
default: LASSERT(false, return FileName());
}
case WmfGraphicsType: mime = wmfMimeType(); break;
default: LASSERT(false, return FileName());
}
// get data
if (!cache_.hasFormat(mime))
return FileName();
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(mime);
// get data
if (!cache_.hasFormat(mime))
return FileName();
// data from ourself or some other LyX instance
QByteArray const ar = cache_.data(mime);
<< "length = " << ar.count());
QFile f(toqstr(filename.absFileName()));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
<< "length = " << ar.count());
QFile f(toqstr(filename.absFileName()));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
<< to_utf8(html) << "' `" << to_utf8(text) << "')");
// We don't convert the encoding of lyx since the encoding of the
// clipboard contents is specified in the data itself
<< to_utf8(html) << "' `" << to_utf8(text) << "')");
// We don't convert the encoding of lyx since the encoding of the
// clipboard contents is specified in the data itself
case PdfGraphicsType: mime = pdfMimeType(); break;
default: LASSERT(false, return false);
}
case PdfGraphicsType: mime = pdfMimeType(); break;
default: LASSERT(false, return false);
}
bool GuiClipboard::hasInternal() const
{
// Windows and Mac OS X does not have the concept of ownership;
bool GuiClipboard::hasInternal() const
{
// Windows and Mac OS X does not have the concept of ownership;
// are notified of changes. However, on Windows ownership is
// emulated by Qt through the OleIsCurrentClipboard() API, while
// on Mac OS X we deal with this issue by ourself.
// are notified of changes. However, on Windows ownership is
// emulated by Qt through the OleIsCurrentClipboard() API, while
// on Mac OS X we deal with this issue by ourself.
+{
+ update();
+#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
+ // Retry on Windows (#10109)
+ if (cache_.formats().count() == 0) {
+ QTimer::singleShot(100, this, SLOT(update()));
+ }
+#endif
+}
+
+void GuiClipboard::update()
{
//Note: we do not really need to run cache_.update() unless the
//data has been changed *and* the GuiClipboard has been queried.
{
//Note: we do not really need to run cache_.update() unless the
//data has been changed *and* the GuiClipboard has been queried.