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:
parent
adde66f0dd
commit
0e62671bc0
@ -171,15 +171,18 @@ QPrint::DeviceState QCocoaPrintDevice::state() const
|
|||||||
|
|
||||||
QPageSize QCocoaPrintDevice::createPageSize(const PMPaper &paper) const
|
QPageSize QCocoaPrintDevice::createPageSize(const PMPaper &paper) const
|
||||||
{
|
{
|
||||||
QCFString key;
|
CFStringRef key;
|
||||||
double width;
|
double width;
|
||||||
double height;
|
double height;
|
||||||
QCFString localizedName;
|
CFStringRef localizedName;
|
||||||
if (PMPaperGetPPDPaperName(paper, &key) == noErr
|
if (PMPaperGetPPDPaperName(paper, &key) == noErr
|
||||||
&& PMPaperGetWidth(paper, &width) == noErr
|
&& PMPaperGetWidth(paper, &width) == noErr
|
||||||
&& PMPaperGetHeight(paper, &height) == noErr
|
&& PMPaperGetHeight(paper, &height) == noErr
|
||||||
&& PMPaperCreateLocalizedName(paper, m_printer, &localizedName) == 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();
|
return QPageSize();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user