summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-06-09 15:34:16 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-06-09 15:34:16 (GMT)
commit292a953258cac0107b820490b09231c0f700bdbe (patch)
treeebcab1e6d4245bc393156053ec4e9c03b2b29b2e /src/corelib/kernel
parent628fd7d141013dcda06d13fa644f44029f317a8c (diff)
downloadQt-292a953258cac0107b820490b09231c0f700bdbe.zip
Qt-292a953258cac0107b820490b09231c0f700bdbe.tar.gz
Qt-292a953258cac0107b820490b09231c0f700bdbe.tar.bz2
make the previous change foolproof
in order to preserve the old behavior in a (corner) case where string was created from the raw data with a shorter lifecycle, just call QString's realloc() that will copy the data and thus guarantee it's consistence later. example: QCFString str; { QString qstr("I'm stupid"); str = QCFString(QString::fromRawData(qstr.data(), qstr.size()); } Merge-request: 2615 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_mac.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index 80cbac9..e45ef50 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -75,6 +75,8 @@ CFStringRef QCFString::toCFStringRef(const QString &string)
QCFString::operator CFStringRef() const
{
if (!type) {
+ if (string.d->data != string.d->array)
+ const_cast<QCFString*>(this)->string.realloc(); // ### Qt5: do we really need this stupid user protection?
const_cast<QCFString*>(this)->type =
CFStringCreateWithCharactersNoCopy(0,
reinterpret_cast<const UniChar *>(string.unicode()),