Cocoa: Fix crash when creating printer object.

Fix reference counting error in QCocoaPrintDevice::
createPageSize(). "key" is accessed with a "Get"
function and should not be released. Switch from
using QCFString to a plain CFStringsRef with manual
ref counting.

Task-number: QTBUG-38023
Change-Id: I04d661bffeb5b3122b0c3c8eaaffdd1af51842fd
Reviewed-by: John Layt <jlayt@kde.org>
This commit is contained in:
Morten Johan Sørvig 2014-04-07 09:24:37 +02:00 committed by The Qt Project
parent adde66f0dd
commit 0e62671bc0

View File

@ -171,15 +171,18 @@ QPrint::DeviceState QCocoaPrintDevice::state() const
QPageSize QCocoaPrintDevice::createPageSize(const PMPaper &paper) const
{
QCFString key;
CFStringRef key;
double width;
double height;
QCFString localizedName;
CFStringRef localizedName;
if (PMPaperGetPPDPaperName(paper, &key) == noErr
&& PMPaperGetWidth(paper, &width) == noErr
&& PMPaperGetHeight(paper, &height) == noErr
&& PMPaperCreateLocalizedName(paper, m_printer, &localizedName) == noErr) {
return(QPlatformPrintDevice::createPageSize(key, QSize(width, height), localizedName));
QPageSize pageSize = QPlatformPrintDevice::createPageSize(QString::fromCFString(key),QSize(width, height),
QString::fromCFString(localizedName));
CFRelease(localizedName);
return pageSize;
}
return QPageSize();
}