From 825c9d9cf72094a9eba7115be3359c92a9b068f8 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 29 Oct 2010 19:44:17 +0200 Subject: [PATCH] When copying a file path from the result list to the clipboard, replace the implicit conversion from latin1 with fromLocal8Bit(), which is not guaranteed to make sense but will probably work in more cases --- src/qtgui/reslist.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index d9e31f58..1951cb26 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -708,11 +708,17 @@ void ResList::menuCopyFN() Rcl::Doc doc; if (getDoc(m_popDoc, doc)) { LOGDEB(("menuCopyFN: Got doc, fn: [%s]\n", doc.url.c_str())); - // Our urls currently always begin with "file://" - QApplication::clipboard()->setText(doc.url.c_str()+7, - QClipboard::Selection); - QApplication::clipboard()->setText(doc.url.c_str()+7, - QClipboard::Clipboard); + // Our urls currently always begin with "file://" + // + // Problem: setText expects a QString. Passing a (const char*) + // as we used to do causes an implicit conversion from + // latin1. File are binary and the right approach would be no + // conversion, but it's probably better (less worse...) to + // make a "best effort" tentative and try to convert from the + // locale's charset than accept the default conversion. + QString qfn = QString::fromLocal8Bit(doc.url.c_str()+7); + QApplication::clipboard()->setText(qfn, QClipboard::Selection); + QApplication::clipboard()->setText(qfn, QClipboard::Clipboard); } } void ResList::menuCopyURL()