Cocoa QPA: Clean up 0 as pointer

We use nil for Objective-C null pointers and nullptr everywhere
else, including CoreFoundation and similar opaque types.

Change-Id: Id75c59413dec54bf4d8e83cf7ed0ff7f3d8bb480
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Gabriel de Dietrich 2018-04-17 18:20:41 -07:00
parent 48defe41e1
commit 7ee44dcb9c
36 changed files with 195 additions and 199 deletions

View File

@ -60,7 +60,7 @@ QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, co
if (system.compare(QLatin1String("cocoa"), Qt::CaseInsensitive) == 0) if (system.compare(QLatin1String("cocoa"), Qt::CaseInsensitive) == 0)
return new QCocoaIntegration(paramList); return new QCocoaIntegration(paramList);
return 0; return nullptr;
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -311,7 +311,7 @@ NSString *getTranslatedAction(const QString &qtAction)
// NSAccessibilityCancelAction; // NSAccessibilityCancelAction;
// NSAccessibilityDeleteAction; // NSAccessibilityDeleteAction;
return 0; return nil;
} }

View File

@ -569,7 +569,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
return NSAccessibilityUnignoredAncestor(self); return NSAccessibilityUnignoredAncestor(self);
// find the deepest child at the point // find the deepest child at the point
QAccessibleInterface *childOfChildInterface = 0; QAccessibleInterface *childOfChildInterface = nullptr;
do { do {
childOfChildInterface = childInterface->childAt(screenPoint.x(), screenPoint.y()); childOfChildInterface = childInterface->childAt(screenPoint.x(), screenPoint.y());
if (childOfChildInterface && childOfChildInterface->isValid()) if (childOfChildInterface && childOfChildInterface->isValid())

View File

@ -113,7 +113,7 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE
static bool qt_filterEvent(NSEvent *event) static bool qt_filterEvent(NSEvent *event)
{ {
if (qApp && qApp->eventDispatcher()-> if (qApp && qApp->eventDispatcher()->
filterNativeEvent(q_macLocalEventType, static_cast<void*>(event), 0)) filterNativeEvent(q_macLocalEventType, static_cast<void*>(event), nullptr))
return true; return true;
if ([event type] == NSApplicationDefined) { if ([event type] == NSApplicationDefined) {

View File

@ -56,13 +56,13 @@ QMimeData *QCocoaClipboard::mimeData(QClipboard::Mode mode)
pasteBoard->sync(); pasteBoard->sync();
return pasteBoard->mimeData(); return pasteBoard->mimeData();
} }
return 0; return nullptr;
} }
void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
{ {
if (QMacPasteboard *pasteBoard = pasteboardForMode(mode)) { if (QMacPasteboard *pasteBoard = pasteboardForMode(mode)) {
if (data == 0) { if (!data) {
pasteBoard->clear(); pasteBoard->clear();
} }
@ -90,7 +90,7 @@ QMacPasteboard *QCocoaClipboard::pasteboardForMode(QClipboard::Mode mode) const
else if (mode == QClipboard::FindBuffer) else if (mode == QClipboard::FindBuffer)
return m_find.data(); return m_find.data();
else else
return 0; return nullptr;
} }
void QCocoaClipboard::handleApplicationStateChanged(Qt::ApplicationState state) void QCocoaClipboard::handleApplicationStateChanged(Qt::ApplicationState state)

View File

@ -74,8 +74,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
{ {
self = [super init]; self = [super init];
mColorPanel = [NSColorPanel sharedColorPanel]; mColorPanel = [NSColorPanel sharedColorPanel];
mHelper = 0; mHelper = nullptr;
mStolenContentView = 0; mStolenContentView = nil;
mPanelButtons = nil; mPanelButtons = nil;
mResultCode = NSModalResponseCancel; mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false; mDialogIsExecuting = false;
@ -115,9 +115,9 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[self restoreOriginalContentView]; [self restoreOriginalContentView];
} else if (!mStolenContentView) { } else if (!mStolenContentView) {
// steal the color panel's contents view // steal the color panel's contents view
mStolenContentView = [mColorPanel contentView]; mStolenContentView = mColorPanel.contentView;
[mStolenContentView retain]; [mStolenContentView retain];
[mColorPanel setContentView:0]; mColorPanel.contentView = nil;
// create a new content view and add the stolen one as a subview // create a new content view and add the stolen one as a subview
mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self]; mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self];
@ -309,7 +309,7 @@ public:
void cleanup(QCocoaColorDialogHelper *helper) void cleanup(QCocoaColorDialogHelper *helper)
{ {
if (mDelegate->mHelper == helper) if (mDelegate->mHelper == helper)
mDelegate->mHelper = 0; mDelegate->mHelper = nullptr;
} }
bool exec() bool exec()

View File

@ -80,15 +80,15 @@ void QCocoaCursor::setPos(const QPoint &position)
pos.x = position.x(); pos.x = position.x();
pos.y = position.y(); pos.y = position.y();
CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, kCGMouseButtonLeft); CGEventRef e = CGEventCreateMouseEvent(nullptr, kCGEventMouseMoved, pos, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, e); CGEventPost(kCGHIDEventTap, e);
CFRelease(e); CFRelease(e);
} }
NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
{ {
if (cursor == nullptr) if (!cursor)
return 0; return nil;
const Qt::CursorShape newShape = cursor->shape(); const Qt::CursorShape newShape = cursor->shape();
NSCursor *cocoaCursor; NSCursor *cocoaCursor;
@ -138,11 +138,11 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor)
cocoaCursor = m_cursors.value(newShape); cocoaCursor = m_cursors.value(newShape);
if (cocoaCursor && cursor->shape() == Qt::BitmapCursor) { if (cocoaCursor && cursor->shape() == Qt::BitmapCursor) {
[cocoaCursor release]; [cocoaCursor release];
cocoaCursor = 0; cocoaCursor = nil;
} }
if (cocoaCursor == 0) { if (!cocoaCursor) {
cocoaCursor = createCursorData(cursor); cocoaCursor = createCursorData(cursor);
if (cocoaCursor == 0) if (!cocoaCursor)
return [NSCursor arrowCursor]; return [NSCursor arrowCursor];
m_cursors.insert(newShape, cocoaCursor); m_cursors.insert(newShape, cocoaCursor);
@ -211,8 +211,8 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
0x07, 0xf0, 0x0f, 0xf8, 0x0f, 0xf8, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x07, 0xf0, 0x0f, 0xf8, 0x0f, 0xf8, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0,
0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0 }; 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0 };
#endif #endif
const uchar *cursorData = 0; const uchar *cursorData = nullptr;
const uchar *cursorMaskData = 0; const uchar *cursorMaskData = nullptr;
QPoint hotspot = cursor->hotSpot(); QPoint hotspot = cursor->hotSpot();
switch (cursor->shape()) { switch (cursor->shape()) {
@ -269,7 +269,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
#endif #endif
default: default:
qWarning("Qt: QCursor::update: Invalid cursor shape %d", cursor->shape()); qWarning("Qt: QCursor::update: Invalid cursor shape %d", cursor->shape());
return 0; return nil;
} }
// Create an NSCursor from image data if this a self-provided cursor. // Create an NSCursor from image data if this a self-provided cursor.
@ -279,7 +279,7 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor)
return (createCursorFromBitmap(&bitmap, &mask, hotspot)); return (createCursorFromBitmap(&bitmap, &mask, hotspot));
} }
return 0; // should not happen, all cases covered above return nil; // should not happen, all cases covered above
} }
NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot) NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot)

View File

@ -50,10 +50,10 @@ QT_BEGIN_NAMESPACE
static const int dragImageMaxChars = 26; static const int dragImageMaxChars = 26;
QCocoaDrag::QCocoaDrag() : QCocoaDrag::QCocoaDrag() :
m_drag(0) m_drag(nullptr)
{ {
m_lastEvent = 0; m_lastEvent = nil;
m_lastView = 0; m_lastView = nil;
} }
QCocoaDrag::~QCocoaDrag() QCocoaDrag::~QCocoaDrag()
@ -73,7 +73,7 @@ QMimeData *QCocoaDrag::dragMimeData()
if (m_drag) if (m_drag)
return m_drag->mimeData(); return m_drag->mimeData();
return 0; return nullptr;
} }
Qt::DropAction QCocoaDrag::defaultAction(Qt::DropActions possibleActions, Qt::DropAction QCocoaDrag::defaultAction(Qt::DropActions possibleActions,
@ -140,7 +140,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
NSPoint event_location = [m_lastEvent locationInWindow]; NSPoint event_location = [m_lastEvent locationInWindow];
NSWindow *theWindow = [m_lastEvent window]; NSWindow *theWindow = [m_lastEvent window];
Q_ASSERT(theWindow != nil); Q_ASSERT(theWindow);
event_location.x -= hotSpot.x(); event_location.x -= hotSpot.x();
CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y(); CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y();
event_location.y -= flippedY; event_location.y -= flippedY;
@ -157,7 +157,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
[nsimage release]; [nsimage release];
m_drag = 0; m_drag = nullptr;
return m_executed_drop_action; return m_executed_drop_action;
} }

View File

@ -110,8 +110,8 @@ class QCocoaEventDispatcher : public QAbstractEventDispatcher
Q_DECLARE_PRIVATE(QCocoaEventDispatcher) Q_DECLARE_PRIVATE(QCocoaEventDispatcher)
public: public:
QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent = 0); QCocoaEventDispatcher(QAbstractEventDispatcherPrivate &priv, QObject *parent = nullptr);
explicit QCocoaEventDispatcher(QObject *parent = 0); explicit QCocoaEventDispatcher(QObject *parent = nullptr);
~QCocoaEventDispatcher(); ~QCocoaEventDispatcher();
bool processEvents(QEventLoop::ProcessEventsFlags flags); bool processEvents(QEventLoop::ProcessEventsFlags flags);

View File

@ -129,11 +129,11 @@ void QCocoaEventDispatcherPrivate::maybeStartCFRunLoopTimer()
{ {
if (timerInfoList.isEmpty()) { if (timerInfoList.isEmpty()) {
// no active timers, so the CFRunLoopTimerRef should not be active either // no active timers, so the CFRunLoopTimerRef should not be active either
Q_ASSERT(runLoopTimerRef == 0); Q_ASSERT(!runLoopTimerRef);
return; return;
} }
if (runLoopTimerRef == 0) { if (!runLoopTimerRef) {
// start the CFRunLoopTimer // start the CFRunLoopTimer
CFAbsoluteTime ttf = CFAbsoluteTimeGetCurrent(); CFAbsoluteTime ttf = CFAbsoluteTimeGetCurrent();
CFTimeInterval interval; CFTimeInterval interval;
@ -150,11 +150,11 @@ void QCocoaEventDispatcherPrivate::maybeStartCFRunLoopTimer()
} }
ttf += interval; ttf += interval;
CFRunLoopTimerContext info = { 0, this, 0, 0, 0 }; CFRunLoopTimerContext info = { 0, this, nullptr, nullptr, nullptr };
// create the timer with a large interval, as recommended by the CFRunLoopTimerSetNextFireDate() // create the timer with a large interval, as recommended by the CFRunLoopTimerSetNextFireDate()
// documentation, since we will adjust the timer's time-to-fire as needed to keep Qt timers working // documentation, since we will adjust the timer's time-to-fire as needed to keep Qt timers working
runLoopTimerRef = CFRunLoopTimerCreate(0, ttf, oneyear, 0, 0, QCocoaEventDispatcherPrivate::runLoopTimerCallback, &info); runLoopTimerRef = CFRunLoopTimerCreate(nullptr, ttf, oneyear, 0, 0, QCocoaEventDispatcherPrivate::runLoopTimerCallback, &info);
Q_ASSERT(runLoopTimerRef != 0); Q_ASSERT(runLoopTimerRef);
CFRunLoopAddTimer(mainRunLoop(), runLoopTimerRef, kCFRunLoopCommonModes); CFRunLoopAddTimer(mainRunLoop(), runLoopTimerRef, kCFRunLoopCommonModes);
} else { } else {
@ -180,12 +180,12 @@ void QCocoaEventDispatcherPrivate::maybeStartCFRunLoopTimer()
void QCocoaEventDispatcherPrivate::maybeStopCFRunLoopTimer() void QCocoaEventDispatcherPrivate::maybeStopCFRunLoopTimer()
{ {
if (runLoopTimerRef == 0) if (!runLoopTimerRef)
return; return;
CFRunLoopTimerInvalidate(runLoopTimerRef); CFRunLoopTimerInvalidate(runLoopTimerRef);
CFRelease(runLoopTimerRef); CFRelease(runLoopTimerRef);
runLoopTimerRef = 0; runLoopTimerRef = nullptr;
} }
void QCocoaEventDispatcher::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *obj) void QCocoaEventDispatcher::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *obj)
@ -368,13 +368,13 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
break; break;
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
NSEvent* event = 0; NSEvent* event = nil;
// First, send all previously excluded input events, if any: // First, send all previously excluded input events, if any:
if (!excludeUserEvents) { if (!excludeUserEvents) {
while (!d->queuedUserInputEvents.isEmpty()) { while (!d->queuedUserInputEvents.isEmpty()) {
event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst()); event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
if (!filterNativeEvent("NSEvent", event, 0)) { if (!filterNativeEvent("NSEvent", event, nullptr)) {
[NSApp sendEvent:event]; [NSApp sendEvent:event];
retVal = true; retVal = true;
} }
@ -432,7 +432,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
retVal = true; retVal = true;
} else { } else {
int lastSerialCopy = d->lastSerial; int lastSerialCopy = d->lastSerial;
bool hadModalSession = d->currentModalSessionCached != 0; const bool hadModalSession = d->currentModalSessionCached;
// We cannot block the thread (and run in a tight loop). // We cannot block the thread (and run in a tight loop).
// Instead we will process all current pending events and return. // Instead we will process all current pending events and return.
d->ensureNSAppInitialized(); d->ensureNSAppInitialized();
@ -471,12 +471,12 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
d->queuedUserInputEvents.append(event); d->queuedUserInputEvents.append(event);
continue; continue;
} }
if (!filterNativeEvent("NSEvent", event, 0)) { if (!filterNativeEvent("NSEvent", event, nullptr)) {
[NSApp sendEvent:event]; [NSApp sendEvent:event];
retVal = true; retVal = true;
} }
} }
} while (!d->interrupt && event != nil); } while (!d->interrupt && event);
} else do { } else do {
// INVARIANT: No modal window is executing. // INVARIANT: No modal window is executing.
event = [NSApp nextEventMatchingMask:NSAnyEventMask event = [NSApp nextEventMatchingMask:NSAnyEventMask
@ -492,12 +492,12 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
continue; continue;
} }
} }
if (!filterNativeEvent("NSEvent", event, 0)) { if (!filterNativeEvent("NSEvent", event, nullptr)) {
[NSApp sendEvent:event]; [NSApp sendEvent:event];
retVal = true; retVal = true;
} }
} }
} while (!d->interrupt && event != nil); } while (!d->interrupt && event);
if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) {
// when called "manually", always send posted events and timers // when called "manually", always send posted events and timers
@ -514,7 +514,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
// event recursion to ensure that we spin the correct modal session. // event recursion to ensure that we spin the correct modal session.
// We do the interruptLater at the end of the function to ensure that we don't // We do the interruptLater at the end of the function to ensure that we don't
// disturb the 'wait for more events' below (as deleteLater will post an event): // disturb the 'wait for more events' below (as deleteLater will post an event):
if (hadModalSession && d->currentModalSessionCached == 0) if (hadModalSession && !d->currentModalSessionCached)
interruptLater = true; interruptLater = true;
} }
bool canWait = (d->threadData->canWait bool canWait = (d->threadData->canWait
@ -611,11 +611,11 @@ void QCocoaEventDispatcherPrivate::temporarilyStopAllModalSessions()
QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
if (info.session) { if (info.session) {
[NSApp endModalSession:info.session]; [NSApp endModalSession:info.session];
info.session = 0; info.session = nullptr;
[(NSWindow*) info.nswindow release]; [(NSWindow*) info.nswindow release];
} }
} }
currentModalSessionCached = 0; currentModalSessionCached = nullptr;
} }
NSModalSession QCocoaEventDispatcherPrivate::currentModalSession() NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
@ -626,7 +626,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
return currentModalSessionCached; return currentModalSessionCached;
if (cocoaModalSessionStack.isEmpty()) if (cocoaModalSessionStack.isEmpty())
return 0; return nullptr;
int sessionCount = cocoaModalSessionStack.size(); int sessionCount = cocoaModalSessionStack.size();
for (int i=0; i<sessionCount; ++i) { for (int i=0; i<sessionCount; ++i) {
@ -728,9 +728,9 @@ void QCocoaEventDispatcherPrivate::cleanupModalSessions()
currentModalSessionCached = info.session; currentModalSessionCached = info.session;
break; break;
} }
currentModalSessionCached = 0; currentModalSessionCached = nullptr;
if (info.session) { if (info.session) {
Q_ASSERT(info.nswindow != 0); Q_ASSERT(info.nswindow);
[NSApp endModalSession:info.session]; [NSApp endModalSession:info.session];
[(NSWindow *)info.nswindow release]; [(NSWindow *)info.nswindow release];
} }
@ -757,10 +757,10 @@ void QCocoaEventDispatcherPrivate::beginModalSession(QWindow *window)
// currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if
// the window pointer is zero, and the session pointer is non-zero (it will be fully // the window pointer is zero, and the session pointer is non-zero (it will be fully
// stopped in cleanupModalSessions()). // stopped in cleanupModalSessions()).
QCocoaModalSessionInfo info = {window, 0, 0}; QCocoaModalSessionInfo info = {window, nullptr, nullptr};
cocoaModalSessionStack.push(info); cocoaModalSessionStack.push(info);
updateChildrenWorksWhenModal(); updateChildrenWorksWhenModal();
currentModalSessionCached = 0; currentModalSessionCached = nullptr;
} }
void QCocoaEventDispatcherPrivate::endModalSession(QWindow *window) void QCocoaEventDispatcherPrivate::endModalSession(QWindow *window)
@ -779,12 +779,12 @@ void QCocoaEventDispatcherPrivate::endModalSession(QWindow *window)
if (!info.window) if (!info.window)
endedSessions++; endedSessions++;
if (info.window == window) { if (info.window == window) {
info.window = 0; info.window = nullptr;
if (i + endedSessions == stackSize-1) { if (i + endedSessions == stackSize-1) {
// The top sessions ended. Interrupt the event dispatcher to // The top sessions ended. Interrupt the event dispatcher to
// start spinning the correct session immediately. // start spinning the correct session immediately.
q->interrupt(); q->interrupt();
currentModalSessionCached = 0; currentModalSessionCached = nullptr;
cleanupModalSessionsNeeded = true; cleanupModalSessionsNeeded = true;
} }
} }
@ -793,13 +793,13 @@ void QCocoaEventDispatcherPrivate::endModalSession(QWindow *window)
QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate() QCocoaEventDispatcherPrivate::QCocoaEventDispatcherPrivate()
: processEventsFlags(0), : processEventsFlags(0),
runLoopTimerRef(0), runLoopTimerRef(nullptr),
blockSendPostedEvents(false), blockSendPostedEvents(false),
currentExecIsNSAppRun(false), currentExecIsNSAppRun(false),
nsAppRunCalledByQt(false), nsAppRunCalledByQt(false),
cleanupModalSessionsNeeded(false), cleanupModalSessionsNeeded(false),
processEventsCalled(0), processEventsCalled(0),
currentModalSessionCached(0), currentModalSessionCached(nullptr),
lastSerial(-1), lastSerial(-1),
interrupt(false) interrupt(false)
{ {
@ -937,7 +937,7 @@ void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
// events somewhere, we post a dummy event to wake it up: // events somewhere, we post a dummy event to wake it up:
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
modifierFlags:0 timestamp:0. windowNumber:0 context:0 modifierFlags:0 timestamp:0. windowNumber:0 context:nil
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO]; subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
} }
@ -1019,7 +1019,7 @@ QCocoaEventDispatcher::~QCocoaEventDispatcher()
CFRelease(d->firstTimeObserver); CFRelease(d->firstTimeObserver);
} }
QtCocoaInterruptDispatcher* QtCocoaInterruptDispatcher::instance = 0; QtCocoaInterruptDispatcher* QtCocoaInterruptDispatcher::instance = nullptr;
QtCocoaInterruptDispatcher::QtCocoaInterruptDispatcher() : cancelled(false) QtCocoaInterruptDispatcher::QtCocoaInterruptDispatcher() : cancelled(false)
{ {
@ -1036,7 +1036,7 @@ QtCocoaInterruptDispatcher::~QtCocoaInterruptDispatcher()
{ {
if (cancelled) if (cancelled)
return; return;
instance = 0; instance = nullptr;
QCocoaEventDispatcher::instance()->interrupt(); QCocoaEventDispatcher::instance()->interrupt();
} }
@ -1046,7 +1046,7 @@ void QtCocoaInterruptDispatcher::cancelInterruptLater()
return; return;
instance->cancelled = true; instance->cancelled = true;
delete instance; delete instance;
instance = 0; instance = nullptr;
} }
void QtCocoaInterruptDispatcher::interruptLater() void QtCocoaInterruptDispatcher::interruptLater()

View File

@ -129,7 +129,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
} else { } else {
mSavePanel = [NSSavePanel savePanel]; mSavePanel = [NSSavePanel savePanel];
[mSavePanel setCanSelectHiddenExtension:YES]; [mSavePanel setCanSelectHiddenExtension:YES];
mOpenPanel = 0; mOpenPanel = nil;
} }
if ([mSavePanel respondsToSelector:@selector(setLevel:)]) if ([mSavePanel respondsToSelector:@selector(setLevel:)])
@ -569,7 +569,7 @@ static QString strippedText(QString s)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QCocoaFileDialogHelper::QCocoaFileDialogHelper() QCocoaFileDialogHelper::QCocoaFileDialogHelper()
:mDelegate(0) : mDelegate(nil)
{ {
} }
@ -579,7 +579,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper()
return; return;
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
[mDelegate release]; [mDelegate release];
mDelegate = 0; mDelegate = nil;
} }
void QCocoaFileDialogHelper::QNSOpenSavePanelDelegate_selectionChanged(const QString &newPath) void QCocoaFileDialogHelper::QNSOpenSavePanelDelegate_selectionChanged(const QString &newPath)

View File

@ -100,9 +100,9 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
{ {
if ((self = [super init])) { if ((self = [super init])) {
mFontPanel = [NSFontPanel sharedFontPanel]; mFontPanel = [NSFontPanel sharedFontPanel];
mHelper = 0; mHelper = nullptr;
mStolenContentView = 0; mStolenContentView = nil;
mPanelButtons = 0; mPanelButtons = nil;
mResultCode = NSModalResponseCancel; mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false; mDialogIsExecuting = false;
mResultSet = false; mResultSet = false;
@ -136,9 +136,9 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[self restoreOriginalContentView]; [self restoreOriginalContentView];
} else if (!mStolenContentView) { } else if (!mStolenContentView) {
// steal the font panel's contents view // steal the font panel's contents view
mStolenContentView = [mFontPanel contentView]; mStolenContentView = mFontPanel.contentView;
[mStolenContentView retain]; [mStolenContentView retain];
[mFontPanel setContentView:0]; mFontPanel.contentView = nil;
// create a new content view and add the stolen one as a subview // create a new content view and add the stolen one as a subview
mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self]; mPanelButtons = [[QNSPanelContentsWrapper alloc] initWithPanelDelegate:self];
@ -160,7 +160,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
// return stolen stuff to its rightful owner // return stolen stuff to its rightful owner
[mStolenContentView removeFromSuperview]; [mStolenContentView removeFromSuperview];
[mFontPanel setContentView:mStolenContentView]; [mFontPanel setContentView:mStolenContentView];
mStolenContentView = 0; mStolenContentView = nil;
[mPanelButtons release]; [mPanelButtons release];
mPanelButtons = nil; mPanelButtons = nil;
} }
@ -192,7 +192,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
// Get selected font // Get selected font
NSFontManager *fontManager = [NSFontManager sharedFontManager]; NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSFont *selectedFont = [fontManager selectedFont]; NSFont *selectedFont = [fontManager selectedFont];
if (selectedFont == nil) { if (!selectedFont) {
selectedFont = [NSFont systemFontOfSize:[NSFont systemFontSize]]; selectedFont = [NSFont systemFontOfSize:[NSFont systemFontSize]];
} }
NSFont *panelFont = [fontManager convertFont:selectedFont]; NSFont *panelFont = [fontManager convertFont:selectedFont];
@ -296,7 +296,7 @@ public:
void cleanup(QCocoaFontDialogHelper *helper) void cleanup(QCocoaFontDialogHelper *helper)
{ {
if (mDelegate->mHelper == helper) if (mDelegate->mHelper == helper)
mDelegate->mHelper = 0; mDelegate->mHelper = nullptr;
} }
bool exec() bool exec()
@ -330,7 +330,7 @@ public:
void setCurrentFont(const QFont &font) void setCurrentFont(const QFont &font)
{ {
NSFontManager *mgr = [NSFontManager sharedFontManager]; NSFontManager *mgr = [NSFontManager sharedFontManager];
const NSFont *nsFont = 0; NSFont *nsFont = nil;
int weight = 5; int weight = 5;
NSFontTraitMask mask = 0; NSFontTraitMask mask = 0;
@ -348,7 +348,7 @@ public:
weight:weight weight:weight
size:fontInfo.pointSize()]; size:fontInfo.pointSize()];
[mgr setSelectedFont:const_cast<NSFont *>(nsFont) isMultiple:NO]; [mgr setSelectedFont:nsFont isMultiple:NO];
mDelegate->mQtFont = font; mDelegate->mQtFont = font;
} }

View File

@ -386,7 +386,7 @@ void QCocoaGLContext::updateSurfaceFormat()
void QCocoaGLContext::doneCurrent() void QCocoaGLContext::doneCurrent()
{ {
if (m_currentWindow && m_currentWindow.data()->handle()) if (m_currentWindow && m_currentWindow.data()->handle())
static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(0); static_cast<QCocoaWindow *>(m_currentWindow.data()->handle())->setCurrentContext(nullptr);
m_currentWindow.clear(); m_currentWindow.clear();

View File

@ -94,11 +94,11 @@ static QCocoaIntegration::Options parseOptions(const QStringList &paramList)
return options; return options;
} }
QCocoaIntegration *QCocoaIntegration::mInstance = 0; QCocoaIntegration *QCocoaIntegration::mInstance = nullptr;
QCocoaIntegration::QCocoaIntegration(const QStringList &paramList) QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
: mOptions(parseOptions(paramList)) : mOptions(parseOptions(paramList))
, mFontDb(0) , mFontDb(nullptr)
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
, mAccessibility(new QCocoaAccessibility) , mAccessibility(new QCocoaAccessibility)
#endif #endif
@ -110,7 +110,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
, mServices(new QCocoaServices) , mServices(new QCocoaServices)
, mKeyboardMapper(new QCocoaKeyMapper) , mKeyboardMapper(new QCocoaKeyMapper)
{ {
if (mInstance != 0) if (mInstance)
qWarning("Creating multiple Cocoa platform integrations is not supported"); qWarning("Creating multiple Cocoa platform integrations is not supported");
mInstance = this; mInstance = this;
@ -186,7 +186,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
QCocoaIntegration::~QCocoaIntegration() QCocoaIntegration::~QCocoaIntegration()
{ {
mInstance = 0; mInstance = nullptr;
qt_resetNSApplicationSendEvent(); qt_resetNSApplicationSendEvent();
@ -296,7 +296,7 @@ QCocoaScreen *QCocoaIntegration::screenForNSScreen(NSScreen *nsScreen)
{ {
NSUInteger index = [[NSScreen screens] indexOfObject:nsScreen]; NSUInteger index = [[NSScreen screens] indexOfObject:nsScreen];
if (index == NSNotFound) if (index == NSNotFound)
return 0; return nullptr;
if (index >= unsigned(mScreens.count())) if (index >= unsigned(mScreens.count()))
updateScreens(); updateScreens();
@ -306,7 +306,7 @@ QCocoaScreen *QCocoaIntegration::screenForNSScreen(NSScreen *nsScreen)
return screen; return screen;
} }
return 0; return nullptr;
} }
bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@ -480,14 +480,14 @@ void QCocoaIntegration::pushPopupWindow(QCocoaWindow *window)
QCocoaWindow *QCocoaIntegration::popPopupWindow() QCocoaWindow *QCocoaIntegration::popPopupWindow()
{ {
if (m_popupWindowStack.isEmpty()) if (m_popupWindowStack.isEmpty())
return 0; return nullptr;
return m_popupWindowStack.takeLast(); return m_popupWindowStack.takeLast();
} }
QCocoaWindow *QCocoaIntegration::activePopupWindow() const QCocoaWindow *QCocoaIntegration::activePopupWindow() const
{ {
if (m_popupWindowStack.isEmpty()) if (m_popupWindowStack.isEmpty())
return 0; return nullptr;
return m_popupWindowStack.front(); return m_popupWindowStack.front();
} }

View File

@ -76,7 +76,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel = 0, SEL backupSel = 0); void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel = nil, SEL backupSel = nil);
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel); void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel);
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -357,17 +357,17 @@ Qt::KeyboardModifiers QCocoaKeyMapper::queryKeyboardModifiers()
bool QCocoaKeyMapper::updateKeyboard() bool QCocoaKeyMapper::updateKeyboard()
{ {
const UCKeyboardLayout *uchrData = 0; const UCKeyboardLayout *uchrData = nullptr;
QCFType<TISInputSourceRef> source = TISCopyInputMethodKeyboardLayoutOverride(); QCFType<TISInputSourceRef> source = TISCopyInputMethodKeyboardLayoutOverride();
if (!source) if (!source)
source = TISCopyCurrentKeyboardInputSource(); source = TISCopyCurrentKeyboardInputSource();
if (keyboard_mode != NullMode && source == currentInputSource) { if (keyboard_mode != NullMode && source == currentInputSource) {
return false; return false;
} }
Q_ASSERT(source != 0); Q_ASSERT(source);
CFDataRef data = static_cast<CFDataRef>(TISGetInputSourceProperty(source, CFDataRef data = static_cast<CFDataRef>(TISGetInputSourceProperty(source,
kTISPropertyUnicodeKeyLayoutData)); kTISPropertyUnicodeKeyLayoutData));
uchrData = data ? reinterpret_cast<const UCKeyboardLayout *>(CFDataGetBytePtr(data)) : 0; uchrData = data ? reinterpret_cast<const UCKeyboardLayout *>(CFDataGetBytePtr(data)) : nullptr;
keyboard_kind = LMGetKbdType(); keyboard_kind = LMGetKbdType();
if (uchrData) { if (uchrData) {
@ -386,7 +386,7 @@ void QCocoaKeyMapper::deleteLayouts()
for (int i = 0; i < 255; ++i) { for (int i = 0; i < 255; ++i) {
if (keyLayout[i]) { if (keyLayout[i]) {
delete keyLayout[i]; delete keyLayout[i];
keyLayout[i] = 0; keyLayout[i] = nullptr;
} }
} }
} }

View File

@ -53,7 +53,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
QCocoaMenu::QCocoaMenu() : QCocoaMenu::QCocoaMenu() :
m_attachedItem(0), m_attachedItem(nil),
m_updateTimer(0), m_updateTimer(0),
m_enabled(true), m_enabled(true),
m_parentEnabled(true), m_parentEnabled(true),
@ -69,7 +69,7 @@ QCocoaMenu::~QCocoaMenu()
{ {
foreach (QCocoaMenuItem *item, m_menuItems) { foreach (QCocoaMenuItem *item, m_menuItems) {
if (item->menuParent() == this) if (item->menuParent() == this)
item->setMenuParent(0); item->setMenuParent(nullptr);
} }
[m_nativeMenu release]; [m_nativeMenu release];
@ -187,7 +187,7 @@ void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
} }
if (cocoaItem->menuParent() == this) if (cocoaItem->menuParent() == this)
cocoaItem->setMenuParent(0); cocoaItem->setMenuParent(nullptr);
// Ignore any parent enabled state // Ignore any parent enabled state
cocoaItem->setParentEnabled(true); cocoaItem->setParentEnabled(true);
@ -335,11 +335,11 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height()); QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0; QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : nullptr;
NSView *view = cocoaWindow ? cocoaWindow->view() : nil; NSView *view = cocoaWindow ? cocoaWindow->view() : nil;
NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil; NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil;
QScreen *screen = 0; QScreen *screen = nullptr;
if (parentWindow) if (parentWindow)
screen = parentWindow->screen(); screen = parentWindow->screen();
if (!screen && !QGuiApplication::screens().isEmpty()) if (!screen && !QGuiApplication::screens().isEmpty())
@ -403,7 +403,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
pressure:1.0]; pressure:1.0];
[NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view]; [NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view];
} else { } else {
[m_nativeMenu popUpMenuPositioningItem:nsItem atLocation:nsPos inView:0]; [m_nativeMenu popUpMenuPositioningItem:nsItem atLocation:nsPos inView:nil];
} }
} }

View File

@ -79,7 +79,7 @@ QCocoaMenuBar::~QCocoaMenuBar()
static_menubars.removeOne(this); static_menubars.removeOne(this);
if (!m_window.isNull() && m_window->menubar() == this) { if (!m_window.isNull() && m_window->menubar() == this) {
m_window->setMenubar(0); m_window->setMenubar(nullptr);
// Delete the children first so they do not cause // Delete the children first so they do not cause
// the native menu items to be hidden after // the native menu items to be hidden after
@ -229,7 +229,7 @@ void QCocoaMenuBar::handleReparent(QWindow *newParentWindow)
if (!m_window.isNull()) if (!m_window.isNull())
m_window->setMenubar(nullptr); m_window->setMenubar(nullptr);
if (newParentWindow == nullptr) { if (!newParentWindow) {
m_window.clear(); m_window.clear();
} else { } else {
newParentWindow->create(); newParentWindow->create();
@ -264,7 +264,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
QCocoaMenuBar *mb = findGlobalMenubar(); QCocoaMenuBar *mb = findGlobalMenubar();
QCocoaWindow *cw = findWindowForMenubar(); QCocoaWindow *cw = findWindowForMenubar();
QWindow *win = cw ? cw->window() : 0; QWindow *win = cw ? cw->window() : nullptr;
if (win && (win->flags() & Qt::Popup) == Qt::Popup) { if (win && (win->flags() & Qt::Popup) == Qt::Popup) {
// context menus, comboboxes, etc. don't need to update the menubar, // context menus, comboboxes, etc. don't need to update the menubar,
// but if an application has only Qt::Tool window(s) on start, // but if an application has only Qt::Tool window(s) on start,

View File

@ -113,7 +113,7 @@ QCocoaMenuItem::~QCocoaMenuItem()
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (m_menu && m_menu->menuParent() == this) if (m_menu && m_menu->menuParent() == this)
m_menu->setMenuParent(0); m_menu->setMenuParent(nullptr);
if (m_merged) { if (m_merged) {
[m_native setHidden:YES]; [m_native setHidden:YES];
} else { } else {
@ -141,7 +141,7 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu)
return; return;
if (m_menu && m_menu->menuParent() == this) { if (m_menu && m_menu->menuParent() == this) {
m_menu->setMenuParent(0); m_menu->setMenuParent(nullptr);
// Free the menu from its parent's influence // Free the menu from its parent's influence
m_menu->propagateEnabledState(true); m_menu->propagateEnabledState(true);
if (m_native && m_menu->attachedItem() == m_native) if (m_native && m_menu->attachedItem() == m_native)

View File

@ -214,7 +214,7 @@
#endif #endif
// Grab the app menu out of the current menu. // Grab the app menu out of the current menu.
int numItems = [mainMenu numberOfItems]; int numItems = [mainMenu numberOfItems];
NSMenuItem *oldAppMenuItem = 0; NSMenuItem *oldAppMenuItem = nil;
for (int i = 0; i < numItems; ++i) { for (int i = 0; i < numItems; ++i) {
NSMenuItem *item = [mainMenu itemAtIndex:i]; NSMenuItem *item = [mainMenu itemAtIndex:i];
if ([item submenu] == appMenu) { if ([item submenu] == appMenu) {

View File

@ -81,20 +81,20 @@ QCocoaNativeInterface::QCocoaNativeInterface()
void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) void *QCocoaNativeInterface::nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context)
{ {
if (!context) if (!context)
return 0; return nullptr;
if (resourceString.toLower() == "nsopenglcontext") if (resourceString.toLower() == "nsopenglcontext")
return nsOpenGLContextForContext(context); return nsOpenGLContextForContext(context);
if (resourceString.toLower() == "cglcontextobj") if (resourceString.toLower() == "cglcontextobj")
return cglContextForContext(context); return cglContextForContext(context);
return 0; return nullptr;
} }
#endif #endif
void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{ {
if (!window->handle()) if (!window->handle())
return 0; return nullptr;
if (resourceString == "nsview") { if (resourceString == "nsview") {
return static_cast<QCocoaWindow *>(window->handle())->m_view; return static_cast<QCocoaWindow *>(window->handle())->m_view;
@ -105,7 +105,7 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
} else if (resourceString == "nswindow") { } else if (resourceString == "nswindow") {
return static_cast<QCocoaWindow *>(window->handle())->nativeWindow(); return static_cast<QCocoaWindow *>(window->handle())->nativeWindow();
} }
return 0; return nullptr;
} }
QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource) QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
@ -143,7 +143,7 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter
if (resource.toLower() == "testcontentborderposition") if (resource.toLower() == "testcontentborderposition")
return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition); return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition);
return 0; return nullptr;
} }
QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport() QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
@ -152,7 +152,7 @@ QPlatformPrinterSupport *QCocoaNativeInterface::createPlatformPrinterSupport()
return new QCocoaPrinterSupport(); return new QCocoaPrinterSupport();
#else #else
qFatal("Printing is not supported when Qt is configured with -no-widgets"); qFatal("Printing is not supported when Qt is configured with -no-widgets");
return 0; return nullptr;
#endif #endif
} }
@ -166,7 +166,7 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
#else #else
Q_UNUSED(printEngine); Q_UNUSED(printEngine);
qFatal("Printing is not supported when Qt is configured with -no-widgets"); qFatal("Printing is not supported when Qt is configured with -no-widgets");
return 0; return nullptr;
#endif #endif
} }
@ -180,10 +180,10 @@ QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0); CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0);
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle) { if (bundle) {
url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), nullptr);
if (url) { if (url) {
QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, nullptr);
QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, nullptr);
if (image) { if (image) {
int width = CGImageGetWidth(image); int width = CGImageGetWidth(image);
int height = CGImageGetHeight(image); int height = CGImageGetHeight(image);
@ -213,7 +213,7 @@ void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context)
NSOpenGLContext *nsOpenGLContext = static_cast<NSOpenGLContext*>(nsOpenGLContextForContext(context)); NSOpenGLContext *nsOpenGLContext = static_cast<NSOpenGLContext*>(nsOpenGLContextForContext(context));
if (nsOpenGLContext) if (nsOpenGLContext)
return [nsOpenGLContext CGLContextObj]; return [nsOpenGLContext CGLContextObj];
return 0; return nullptr;
} }
void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context) void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
@ -224,7 +224,7 @@ void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
return cocoaGLContext->nsOpenGLContext(); return cocoaGLContext->nsOpenGLContext();
} }
} }
return 0; return nullptr;
} }
#endif #endif

View File

@ -67,17 +67,17 @@ static QPrint::DuplexMode macToDuplexMode(const PMDuplexMode &mode)
QCocoaPrintDevice::QCocoaPrintDevice() QCocoaPrintDevice::QCocoaPrintDevice()
: QPlatformPrintDevice(), : QPlatformPrintDevice(),
m_printer(0), m_printer(nullptr),
m_session(0), m_session(nullptr),
m_ppd(0) m_ppd(nullptr)
{ {
} }
QCocoaPrintDevice::QCocoaPrintDevice(const QString &id) QCocoaPrintDevice::QCocoaPrintDevice(const QString &id)
: QPlatformPrintDevice(id), : QPlatformPrintDevice(id),
m_printer(0), m_printer(nullptr),
m_session(0), m_session(nullptr),
m_ppd(0) m_ppd(nullptr)
{ {
if (!id.isEmpty()) { if (!id.isEmpty()) {
m_printer = PMPrinterCreateFromPrinterID(id.toCFString()); m_printer = PMPrinterCreateFromPrinterID(id.toCFString());
@ -443,7 +443,7 @@ bool QCocoaPrintDevice::openPpdFile()
{ {
if (m_ppd) if (m_ppd)
ppdClose(m_ppd); ppdClose(m_ppd);
m_ppd = 0; m_ppd = nullptr;
CFURLRef ppdURL = NULL; CFURLRef ppdURL = NULL;
char ppdPath[MAXPATHLEN]; char ppdPath[MAXPATHLEN];
if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr
@ -470,7 +470,7 @@ PMPaper QCocoaPrintDevice::macPaper(const QPageSize &pageSize) const
if (m_macPapers.contains(pageSize.key())) if (m_macPapers.contains(pageSize.key()))
return m_macPapers.value(pageSize.key()); return m_macPapers.value(pageSize.key());
// For any other page size, whether custom or just unsupported, needs to be a custom PMPaper // For any other page size, whether custom or just unsupported, needs to be a custom PMPaper
PMPaper paper = 0; PMPaper paper = nullptr;
PMPaperMargins paperMargins; PMPaperMargins paperMargins;
paperMargins.left = m_customMargins.left(); paperMargins.left = m_customMargins.left();
paperMargins.right = m_customMargins.right(); paperMargins.right = m_customMargins.right();

View File

@ -164,7 +164,7 @@ QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
// belowWindowWithWindowNumber] may return windows that are not interesting // belowWindowWithWindowNumber] may return windows that are not interesting
// to Qt. The search iterates until a suitable window or no window is found. // to Qt. The search iterates until a suitable window or no window is found.
NSInteger topWindowNumber = 0; NSInteger topWindowNumber = 0;
QWindow *window = 0; QWindow *window = nullptr;
do { do {
// Get the top-most window, below any previously rejected window. // Get the top-most window, below any previously rejected window.
topWindowNumber = [NSWindow windowNumberAtPoint:screenPoint topWindowNumber = [NSWindow windowNumberAtPoint:screenPoint
@ -172,7 +172,7 @@ QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
// Continue the search if the window does not belong to this process. // Continue the search if the window does not belong to this process.
NSWindow *nsWindow = [NSApp windowWithWindowNumber:topWindowNumber]; NSWindow *nsWindow = [NSApp windowWithWindowNumber:topWindowNumber];
if (nsWindow == 0) if (!nsWindow)
continue; continue;
// Continue the search if the window does not belong to Qt. // Continue the search if the window does not belong to Qt.

View File

@ -129,7 +129,7 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes()
QColor qc; QColor qc;
for (int i = 0; i < mac_widget_colors_count; i++) { for (int i = 0; i < mac_widget_colors_count; i++) {
QPalette &pal = *qt_mac_createSystemPalette(); QPalette &pal = *qt_mac_createSystemPalette();
if (mac_widget_colors[i].active != 0) { if (mac_widget_colors[i].active) {
qc = qt_mac_toQColor(mac_widget_colors[i].active); qc = qt_mac_toQColor(mac_widget_colors[i].active);
pal.setColor(QPalette::Active, QPalette::Text, qc); pal.setColor(QPalette::Active, QPalette::Text, qc);
pal.setColor(QPalette::Inactive, QPalette::Text, qc); pal.setColor(QPalette::Inactive, QPalette::Text, qc);

View File

@ -55,7 +55,7 @@ class QSystemTrayIconSys;
class Q_GUI_EXPORT QCocoaSystemTrayIcon : public QPlatformSystemTrayIcon class Q_GUI_EXPORT QCocoaSystemTrayIcon : public QPlatformSystemTrayIcon
{ {
public: public:
QCocoaSystemTrayIcon() : m_sys(0) {} QCocoaSystemTrayIcon() : m_sys(nullptr) {}
void init() override; void init() override;
void cleanup() override; void cleanup() override;

View File

@ -147,7 +147,7 @@ QRect QCocoaSystemTrayIcon::geometry() const
void QCocoaSystemTrayIcon::cleanup() void QCocoaSystemTrayIcon::cleanup()
{ {
delete m_sys; delete m_sys;
m_sys = 0; m_sys = nullptr;
} }
static bool heightCompareFunction (QSize a, QSize b) { return (a.height() < b.height()); } static bool heightCompareFunction (QSize a, QSize b) { return (a.height() < b.height()); }
@ -363,7 +363,7 @@ QT_END_NAMESPACE
self = [super init]; self = [super init];
if (self) { if (self) {
item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
menu = 0; menu = nullptr;
systray = sys; systray = sys;
imageCell = [[QNSImageView alloc] initWithParent:self]; imageCell = [[QNSImageView alloc] initWithParent:self];
[item setView: imageCell]; [item setView: imageCell];

View File

@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE
const char *QCocoaTheme::name = "cocoa"; const char *QCocoaTheme::name = "cocoa";
QCocoaTheme::QCocoaTheme() QCocoaTheme::QCocoaTheme()
:m_systemPalette(0) : m_systemPalette(nullptr)
{ {
m_notificationReceiver = [[QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver) alloc] initWithPrivate:this]; m_notificationReceiver = [[QT_MANGLE_NAMESPACE(QCocoaThemeNotificationReceiver) alloc] initWithPrivate:this];
[[NSNotificationCenter defaultCenter] addObserver:m_notificationReceiver [[NSNotificationCenter defaultCenter] addObserver:m_notificationReceiver
@ -145,7 +145,7 @@ bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const
return false; return false;
} }
QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const QPlatformDialogHelper *QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const
{ {
switch (dialogType) { switch (dialogType) {
#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) #if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog)
@ -161,7 +161,7 @@ QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialo
return new QCocoaFontDialogHelper(); return new QCocoaFontDialogHelper();
#endif #endif
default: default:
return 0; return nullptr;
} }
} }
@ -181,9 +181,9 @@ const QPalette *QCocoaTheme::palette(Palette type) const
} else { } else {
if (m_palettes.isEmpty()) if (m_palettes.isEmpty())
m_palettes = qt_mac_createRolePalettes(); m_palettes = qt_mac_createRolePalettes();
return m_palettes.value(type, 0); return m_palettes.value(type, nullptr);
} }
return 0; return nullptr;
} }
QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts() QHash<QPlatformTheme::Font, QFont *> qt_mac_createRoleFonts()
@ -197,7 +197,7 @@ const QFont *QCocoaTheme::font(Font type) const
if (m_fonts.isEmpty()) { if (m_fonts.isEmpty()) {
m_fonts = qt_mac_createRoleFonts(); m_fonts = qt_mac_createRoleFonts();
} }
return m_fonts.value(type, 0); return m_fonts.value(type, nullptr);
} }
//! \internal //! \internal

View File

@ -143,7 +143,7 @@ const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle) QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
: QPlatformWindow(win) : QPlatformWindow(win)
, m_view(nil) , m_view(nil)
, m_nsWindow(0) , m_nsWindow(nil)
, m_lastReportedWindowState(Qt::WindowNoState) , m_lastReportedWindowState(Qt::WindowNoState)
, m_windowModality(Qt::NonModal) , m_windowModality(Qt::NonModal)
, m_windowUnderMouse(false) , m_windowUnderMouse(false)
@ -152,9 +152,9 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
, m_inSetGeometry(false) , m_inSetGeometry(false)
, m_inSetStyleMask(false) , m_inSetStyleMask(false)
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
, m_glContext(0) , m_glContext(nullptr)
#endif #endif
, m_menubar(0) , m_menubar(nullptr)
, m_needsInvalidateShadow(false) , m_needsInvalidateShadow(false)
, m_hasModalSession(false) , m_hasModalSession(false)
, m_frameStrutEventsEnabled(false) , m_frameStrutEventsEnabled(false)
@ -316,7 +316,7 @@ void QCocoaWindow::setVisible(bool visible)
m_inSetVisible = true; m_inSetVisible = true;
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = 0; QCocoaWindow *parentCocoaWindow = nullptr;
if (window()->transientParent()) if (window()->transientParent())
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle()); parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
@ -368,13 +368,13 @@ void QCocoaWindow::setVisible(bool visible)
} else if (window()->modality() != Qt::NonModal) { } else if (window()->modality() != Qt::NonModal) {
// show the window as application modal // show the window as application modal
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
Q_ASSERT(cocoaEventDispatcher != 0); Q_ASSERT(cocoaEventDispatcher);
QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
cocoaEventDispatcherPrivate->beginModalSession(window()); cocoaEventDispatcherPrivate->beginModalSession(window());
m_hasModalSession = true; m_hasModalSession = true;
} else if ([m_view.window canBecomeKeyWindow]) { } else if ([m_view.window canBecomeKeyWindow]) {
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0; QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = nullptr;
if (cocoaEventDispatcher) if (cocoaEventDispatcher)
cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
@ -413,7 +413,7 @@ void QCocoaWindow::setVisible(bool visible)
m_glContext->windowWasHidden(); m_glContext->windowWasHidden();
#endif #endif
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher()); QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0; QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = nullptr;
if (cocoaEventDispatcher) if (cocoaEventDispatcher)
cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher)); cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
if (isContentView()) { if (isContentView()) {
@ -481,7 +481,8 @@ NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
// Any "special" window should be in at least the same level as its parent. // Any "special" window should be in at least the same level as its parent.
if (type != Qt::Window) { if (type != Qt::Window) {
const QWindow * const transientParent = window()->transientParent(); const QWindow * const transientParent = window()->transientParent();
const QCocoaWindow * const transientParentWindow = transientParent ? static_cast<QCocoaWindow *>(transientParent->handle()) : 0; const QCocoaWindow * const transientParentWindow = transientParent ?
static_cast<QCocoaWindow *>(transientParent->handle()) : nullptr;
if (transientParentWindow) if (transientParentWindow)
windowLevel = qMax([transientParentWindow->nativeWindow() level], windowLevel); windowLevel = qMax([transientParentWindow->nativeWindow() level], windowLevel);
} }
@ -1276,18 +1277,13 @@ void QCocoaWindow::recreateWindowIfNeeded()
// with a NSWindow contentView pointing to a deallocated NSView. // with a NSWindow contentView pointing to a deallocated NSView.
m_view.window.contentView = nil; m_view.window.contentView = nil;
} }
m_nsWindow = 0; m_nsWindow = nil;
} }
} }
if (shouldBeContentView) { if (shouldBeContentView && !m_nsWindow) {
bool noPreviousWindow = m_nsWindow == 0;
QCocoaNSWindow *newWindow = nullptr;
if (noPreviousWindow)
newWindow = createNSWindow(shouldBePanel);
// Move view to new NSWindow if needed // Move view to new NSWindow if needed
if (newWindow) { if (auto *newWindow = createNSWindow(shouldBePanel)) {
qCDebug(lcQpaWindow) << "Ensuring that" << m_view << "is content view for" << newWindow; qCDebug(lcQpaWindow) << "Ensuring that" << m_view << "is content view for" << newWindow;
[m_view setPostsFrameChangedNotifications:NO]; [m_view setPostsFrameChangedNotifications:NO];
[newWindow setContentView:m_view]; [newWindow setContentView:m_view];

View File

@ -54,7 +54,7 @@ public:
enum DataRequestType { EagerRequest, LazyRequest }; enum DataRequestType { EagerRequest, LazyRequest };
private: private:
struct Promise { struct Promise {
Promise() : itemId(0), convertor(0) { } Promise() : itemId(0), convertor(nullptr) { }
static Promise eagerPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0); static Promise eagerPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
static Promise lazyPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0); static Promise lazyPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
@ -79,7 +79,7 @@ private:
public: public:
QMacPasteboard(PasteboardRef p, uchar mime_type=0); QMacPasteboard(PasteboardRef p, uchar mime_type=0);
QMacPasteboard(uchar mime_type); QMacPasteboard(uchar mime_type);
QMacPasteboard(CFStringRef name=0, uchar mime_type=0); QMacPasteboard(CFStringRef name=nullptr, uchar mime_type=0);
~QMacPasteboard(); ~QMacPasteboard();
bool hasFlavor(QString flavor) const; bool hasFlavor(QString flavor) const;

View File

@ -75,7 +75,7 @@ QMacPasteboard::Promise::Promise(int itemId, QMacInternalPasteboardMime *c, QStr
// Request the data from the application immediately for eager requests. // Request the data from the application immediately for eager requests.
if (dataRequestType == QMacPasteboard::EagerRequest) { if (dataRequestType == QMacPasteboard::EagerRequest) {
variantData = md->variantData(m); variantData = md->variantData(m);
mimeData = 0; mimeData = nullptr;
} else { } else {
mimeData = md; mimeData = md;
} }
@ -94,8 +94,8 @@ QMacPasteboard::QMacPasteboard(uchar mt)
{ {
mac_mime_source = false; mac_mime_source = false;
mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL); mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL);
paste = 0; paste = nullptr;
OSStatus err = PasteboardCreate(0, &paste); OSStatus err = PasteboardCreate(nullptr, &paste);
if (err == noErr) { if (err == noErr) {
PasteboardSetPromiseKeeper(paste, promiseKeeper, this); PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
} else { } else {
@ -108,7 +108,7 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
{ {
mac_mime_source = false; mac_mime_source = false;
mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL); mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL);
paste = 0; paste = nullptr;
OSStatus err = PasteboardCreate(name, &paste); OSStatus err = PasteboardCreate(name, &paste);
if (err == noErr) { if (err == noErr) {
PasteboardSetPromiseKeeper(paste, promiseKeeper, this); PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
@ -165,7 +165,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
// we have promised this data, but won't be able to convert, so return null data. // we have promised this data, but won't be able to convert, so return null data.
// This helps in making the application/x-qt-mime-type-name hidden from normal use. // This helps in making the application/x-qt-mime-type-name hidden from normal use.
QByteArray ba; QByteArray ba;
QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size()); QCFType<CFDataRef> data = CFDataCreate(nullptr, (UInt8*)ba.constData(), ba.size());
PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags); PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
return noErr; return noErr;
} }
@ -196,7 +196,7 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
if (md.size() <= promise.offset) if (md.size() <= promise.offset)
return cantGetFlavorErr; return cantGetFlavorErr;
const QByteArray &ba = md[promise.offset]; const QByteArray &ba = md[promise.offset];
QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size()); QCFType<CFDataRef> data = CFDataCreate(nullptr, (UInt8*)ba.constData(), ba.size());
PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags); PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
return noErr; return noErr;
} }
@ -553,7 +553,7 @@ QMacPasteboard::sync() const
const bool fromGlobal = PasteboardSynchronize(paste) & kPasteboardModified; const bool fromGlobal = PasteboardSynchronize(paste) & kPasteboardModified;
if (fromGlobal) if (fromGlobal)
const_cast<QMacPasteboard *>(this)->setMimeData(0); const_cast<QMacPasteboard *>(this)->setMimeData(nullptr);
#ifdef DEBUG_PASTEBOARD #ifdef DEBUG_PASTEBOARD
if (fromGlobal) if (fromGlobal)

View File

@ -107,7 +107,7 @@ QCocoaTouch *QCocoaTouch::findQCocoaTouch(NSTouch *nstouch)
qint64 identity = qint64([nstouch identity]); qint64 identity = qint64([nstouch identity]);
if (_currentTouches.contains(identity)) if (_currentTouches.contains(identity))
return _currentTouches.value(identity); return _currentTouches.value(identity);
return 0; return nullptr;
} }
Qt::TouchPointState QCocoaTouch::toTouchPointState(NSTouchPhase nsState) Qt::TouchPointState QCocoaTouch::toTouchPointState(NSTouchPhase nsState)

View File

@ -148,18 +148,18 @@
m_frameStrutButtons = Qt::NoButton; m_frameStrutButtons = Qt::NoButton;
m_sendKeyEvent = false; m_sendKeyEvent = false;
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
m_glContext = 0; m_glContext = nullptr;
m_shouldSetGLContextinDrawRect = false; m_shouldSetGLContextinDrawRect = false;
#endif #endif
currentCustomDragTypes = 0; currentCustomDragTypes = nullptr;
m_dontOverrideCtrlLMB = false; m_dontOverrideCtrlLMB = false;
m_sendUpAsRightButton = false; m_sendUpAsRightButton = false;
m_inputSource = 0; m_inputSource = nil;
m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self]; m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self];
m_resendKeyEvent = false; m_resendKeyEvent = false;
m_scrolling = false; m_scrolling = false;
m_updatingDrag = false; m_updatingDrag = false;
m_currentlyInterpretedKeyEvent = 0; m_currentlyInterpretedKeyEvent = nil;
self.focusRingType = NSFocusRingTypeNone; self.focusRingType = NSFocusRingTypeNone;
self.cursor = nil; self.cursor = nil;
m_updateRequested = false; m_updateRequested = false;

View File

@ -98,8 +98,8 @@ CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr)
for (int x = sx; x < sw; ++x) for (int x = sx; x < sw; ++x)
*(dptr+(offset++)) = (*(srow+x) & mask) ? 255 : 0; *(dptr+(offset++)) = (*(srow+x) & mask) ? 255 : 0;
} }
QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(0, dptr, nbytes, qt_mac_cgimage_data_free); QCFType<CGDataProviderRef> provider = CGDataProviderCreateWithData(nullptr, dptr, nbytes, qt_mac_cgimage_data_free);
return CGImageMaskCreate(sw, sh, 8, 8, nbytes / sh, provider, 0, 0); return CGImageMaskCreate(sw, sh, 8, 8, nbytes / sh, provider, nullptr, false);
} }
//conversion //conversion
@ -287,16 +287,16 @@ static void qt_mac_draw_pattern(void *info, CGContextRef c)
Q_ASSERT(pat->data.bytes); Q_ASSERT(pat->data.bytes);
w = h = 8; w = h = 8;
#if (QMACPATTERN_MASK_MULTIPLIER == 1) #if (QMACPATTERN_MASK_MULTIPLIER == 1)
CGDataProviderRef provider = CGDataProviderCreateWithData(0, pat->data.bytes, w*h, 0); CGDataProviderRef provider = CGDataProviderCreateWithData(nullptr, pat->data.bytes, w*h, nullptr);
pat->image = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0, false); pat->image = CGImageMaskCreate(w, h, 1, 1, 1, provider, nullptr, false);
CGDataProviderRelease(provider); CGDataProviderRelease(provider);
#else #else
const int numBytes = (w*h)/sizeof(uchar); const int numBytes = (w*h)/sizeof(uchar);
uchar xor_bytes[numBytes]; uchar xor_bytes[numBytes];
for (int i = 0; i < numBytes; ++i) for (int i = 0; i < numBytes; ++i)
xor_bytes[i] = pat->data.bytes[i] ^ 0xFF; xor_bytes[i] = pat->data.bytes[i] ^ 0xFF;
CGDataProviderRef provider = CGDataProviderCreateWithData(0, xor_bytes, w*h, 0); CGDataProviderRef provider = CGDataProviderCreateWithData(nullptr, xor_bytes, w*h, nullptr);
CGImageRef swatch = CGImageMaskCreate(w, h, 1, 1, 1, provider, 0, false); CGImageRef swatch = CGImageMaskCreate(w, h, 1, 1, 1, provider, nullptr, false);
CGDataProviderRelease(provider); CGDataProviderRelease(provider);
const QColor c0(0, 0, 0, 0), c1(255, 255, 255, 255); const QColor c0(0, 0, 0, 0), c1(255, 255, 255, 255);
@ -399,9 +399,9 @@ QCoreGraphicsPaintEngine::begin(QPaintDevice *pdev)
d->orig_xform = CGContextGetCTM(d->hd); d->orig_xform = CGContextGetCTM(d->hd);
if (d->shading) { if (d->shading) {
CGShadingRelease(d->shading); CGShadingRelease(d->shading);
d->shading = 0; d->shading = nullptr;
} }
d->setClip(0); //clear the context's clipping d->setClip(nullptr); //clear the context's clipping
} }
setActive(true); setActive(true);
@ -445,12 +445,12 @@ QCoreGraphicsPaintEngine::end()
CGShadingRelease(d->shading); CGShadingRelease(d->shading);
d->shading = 0; d->shading = 0;
} }
d->pdev = 0; d->pdev = nullptr;
if (d->hd) { if (d->hd) {
d->restoreGraphicsState(); d->restoreGraphicsState();
CGContextSynchronize(d->hd); CGContextSynchronize(d->hd);
CGContextRelease(d->hd); CGContextRelease(d->hd);
d->hd = 0; d->hd = nullptr;
} }
return true; return true;
} }
@ -545,7 +545,7 @@ QCoreGraphicsPaintEngine::updateBrush(const QBrush &brush, const QPointF &brushO
if (d->shading) { if (d->shading) {
CGShadingRelease(d->shading); CGShadingRelease(d->shading);
d->shading = 0; d->shading = nullptr;
} }
d->setFillBrush(brushOrigin); d->setFillBrush(brushOrigin);
} }
@ -592,7 +592,7 @@ QCoreGraphicsPaintEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperatio
if (d->current.clipEnabled) { if (d->current.clipEnabled) {
d->current.clipEnabled = false; d->current.clipEnabled = false;
d->current.clip = QRegion(); d->current.clip = QRegion();
d->setClip(0); d->setClip(nullptr);
} }
} else { } else {
if (!d->current.clipEnabled) if (!d->current.clipEnabled)
@ -601,7 +601,7 @@ QCoreGraphicsPaintEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperatio
QRegion clipRegion(p.toFillPolygon().toPolygon(), p.fillRule()); QRegion clipRegion(p.toFillPolygon().toPolygon(), p.fillRule());
if (op == Qt::ReplaceClip) { if (op == Qt::ReplaceClip) {
d->current.clip = clipRegion; d->current.clip = clipRegion;
d->setClip(0); d->setClip(nullptr);
if (p.isEmpty()) { if (p.isEmpty()) {
CGRect rect = CGRectMake(0, 0, 0, 0); CGRect rect = CGRectMake(0, 0, 0, 0);
CGContextClipToRect(d->hd, rect); CGContextClipToRect(d->hd, rect);
@ -630,7 +630,7 @@ QCoreGraphicsPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOp
if (op == Qt::NoClip) { if (op == Qt::NoClip) {
d->current.clipEnabled = false; d->current.clipEnabled = false;
d->current.clip = QRegion(); d->current.clip = QRegion();
d->setClip(0); d->setClip(nullptr);
} else { } else {
if (!d->current.clipEnabled) if (!d->current.clipEnabled)
op = Qt::ReplaceClip; op = Qt::ReplaceClip;
@ -676,7 +676,7 @@ QCoreGraphicsPaintEngine::drawRects(const QRectF *rects, int rectCount)
QRectF r = rects[i]; QRectF r = rects[i];
CGMutablePathRef path = CGPathCreateMutable(); CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, 0, qt_mac_compose_rect(r)); CGPathAddRect(path, nullptr, qt_mac_compose_rect(r));
d->drawPath(QCoreGraphicsPaintEnginePrivate::CGFill|QCoreGraphicsPaintEnginePrivate::CGStroke, d->drawPath(QCoreGraphicsPaintEnginePrivate::CGFill|QCoreGraphicsPaintEnginePrivate::CGStroke,
path); path);
CGPathRelease(path); CGPathRelease(path);
@ -698,8 +698,8 @@ QCoreGraphicsPaintEngine::drawPoints(const QPointF *points, int pointCount)
CGMutablePathRef path = CGPathCreateMutable(); CGMutablePathRef path = CGPathCreateMutable();
for (int i=0; i < pointCount; i++) { for (int i=0; i < pointCount; i++) {
float x = points[i].x(), y = points[i].y(); float x = points[i].x(), y = points[i].y();
CGPathMoveToPoint(path, 0, x, y); CGPathMoveToPoint(path, nullptr, x, y);
CGPathAddLineToPoint(path, 0, x+0.001, y); CGPathAddLineToPoint(path, nullptr, x+0.001, y);
} }
bool doRestore = false; bool doRestore = false;
@ -745,11 +745,11 @@ QCoreGraphicsPaintEngine::drawPolygon(const QPointF *points, int pointCount, Pol
return; return;
CGMutablePathRef path = CGPathCreateMutable(); CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, 0, points[0].x(), points[0].y()); CGPathMoveToPoint(path, nullptr, points[0].x(), points[0].y());
for (int x = 1; x < pointCount; ++x) for (int x = 1; x < pointCount; ++x)
CGPathAddLineToPoint(path, 0, points[x].x(), points[x].y()); CGPathAddLineToPoint(path, nullptr, points[x].x(), points[x].y());
if (mode != PolylineMode && points[0] != points[pointCount-1]) if (mode != PolylineMode && points[0] != points[pointCount-1])
CGPathAddLineToPoint(path, 0, points[0].x(), points[0].y()); CGPathAddLineToPoint(path, nullptr, points[0].x(), points[0].y());
uint op = QCoreGraphicsPaintEnginePrivate::CGStroke; uint op = QCoreGraphicsPaintEnginePrivate::CGStroke;
if (mode != PolylineMode) if (mode != PolylineMode)
op |= mode == OddEvenMode ? QCoreGraphicsPaintEnginePrivate::CGEOFill op |= mode == OddEvenMode ? QCoreGraphicsPaintEnginePrivate::CGEOFill
@ -770,8 +770,8 @@ QCoreGraphicsPaintEngine::drawLines(const QLineF *lines, int lineCount)
CGMutablePathRef path = CGPathCreateMutable(); CGMutablePathRef path = CGPathCreateMutable();
for (int i = 0; i < lineCount; i++) { for (int i = 0; i < lineCount; i++) {
const QPointF start = lines[i].p1(), end = lines[i].p2(); const QPointF start = lines[i].p1(), end = lines[i].p2();
CGPathMoveToPoint(path, 0, start.x(), start.y()); CGPathMoveToPoint(path, nullptr, start.x(), start.y());
CGPathAddLineToPoint(path, 0, end.x(), end.y()); CGPathAddLineToPoint(path, nullptr, end.x(), end.y());
} }
d->drawPath(QCoreGraphicsPaintEnginePrivate::CGStroke, path); d->drawPath(QCoreGraphicsPaintEnginePrivate::CGStroke, path);
CGPathRelease(path); CGPathRelease(path);
@ -870,7 +870,7 @@ QCoreGraphicsPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap
CGPatternRef pat = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height), CGPatternRef pat = CGPatternCreate(qpattern, CGRectMake(0, 0, width, height),
trans, width, height, trans, width, height,
kCGPatternTilingNoDistortion, true, &callbks); kCGPatternTilingNoDistortion, true, &callbks);
CGColorSpaceRef cs = CGColorSpaceCreatePattern(0); CGColorSpaceRef cs = CGColorSpaceCreatePattern(nullptr);
CGContextSetFillColorSpace(d->hd, cs); CGContextSetFillColorSpace(d->hd, cs);
CGFloat component = 1.0; //just one CGFloat component = 1.0; //just one
CGContextSetFillPattern(d->hd, pat, &component); CGContextSetFillPattern(d->hd, pat, &component);
@ -1198,9 +1198,9 @@ void QCoreGraphicsPaintEnginePrivate::setFillBrush(const QPointF &offset)
Q_ASSERT(grad->spread() == QGradient::PadSpread); Q_ASSERT(grad->spread() == QGradient::PadSpread);
static const CGFloat domain[] = { 0.0f, +1.0f }; static const CGFloat domain[] = { 0.0f, +1.0f };
static const CGFunctionCallbacks callbacks = { 0, qt_mac_color_gradient_function, 0 }; static const CGFunctionCallbacks callbacks = { 0, qt_mac_color_gradient_function, nullptr };
CGFunctionRef fill_func = CGFunctionCreate(reinterpret_cast<void *>(&current.brush), CGFunctionRef fill_func = CGFunctionCreate(reinterpret_cast<void *>(&current.brush),
1, domain, 4, 0, &callbacks); 1, domain, 4, nullptr, &callbacks);
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB) CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB)
if (bs == Qt::LinearGradientPattern) { if (bs == Qt::LinearGradientPattern) {
@ -1233,7 +1233,7 @@ void QCoreGraphicsPaintEnginePrivate::setFillBrush(const QPointF &offset)
QMacPattern *qpattern = new QMacPattern; QMacPattern *qpattern = new QMacPattern;
qpattern->pdev = pdev; qpattern->pdev = pdev;
CGFloat components[4] = { 1.0, 1.0, 1.0, 1.0 }; CGFloat components[4] = { 1.0, 1.0, 1.0, 1.0 };
CGColorSpaceRef base_colorspace = 0; CGColorSpaceRef base_colorspace = nullptr;
if (bs == Qt::TexturePattern) { if (bs == Qt::TexturePattern) {
qpattern->data.pixmap = current.brush.texture(); qpattern->data.pixmap = current.brush.texture();
if (qpattern->data.pixmap.isQBitmap()) { if (qpattern->data.pixmap.isQBitmap()) {
@ -1291,7 +1291,7 @@ QCoreGraphicsPaintEnginePrivate::setClip(const QRegion *rgn)
if (!sysClip.isEmpty()) if (!sysClip.isEmpty())
qt_mac_clip_cg(hd, sysClip, &orig_xform); qt_mac_clip_cg(hd, sysClip, &orig_xform);
if (rgn) if (rgn)
qt_mac_clip_cg(hd, *rgn, 0); qt_mac_clip_cg(hd, *rgn, nullptr);
} }
} }
@ -1404,7 +1404,7 @@ void QCoreGraphicsPaintEnginePrivate::drawPath(uchar ops, CGMutablePathRef path)
t.transform = qt_mac_convert_transform_to_cg(current.transform); t.transform = qt_mac_convert_transform_to_cg(current.transform);
t.path = CGPathCreateMutable(); t.path = CGPathCreateMutable();
CGPathApply(path, &t, qt_mac_cg_transform_path_apply); //transform the path CGPathApply(path, &t, qt_mac_cg_transform_path_apply); //transform the path
setTransform(0); //unset the context transform setTransform(nullptr); //unset the context transform
CGContextSetLineWidth(hd, cosmeticPenSize); CGContextSetLineWidth(hd, cosmeticPenSize);
CGContextAddPath(hd, t.path); CGContextAddPath(hd, t.path);
CGPathRelease(t.path); CGPathRelease(t.path);

View File

@ -135,7 +135,7 @@ class QCoreGraphicsPaintEnginePrivate : public QPaintEnginePrivate
Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine) Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine)
public: public:
QCoreGraphicsPaintEnginePrivate() QCoreGraphicsPaintEnginePrivate()
: hd(0), shading(0), stackCount(0), complexXForm(false), disabledSmoothFonts(false) : hd(nullptr), shading(nullptr), stackCount(0), complexXForm(false), disabledSmoothFonts(false)
{ {
} }
@ -164,8 +164,8 @@ public:
//internal functions //internal functions
enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 }; enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 };
void drawPath(uchar ops, CGMutablePathRef path = 0); void drawPath(uchar ops, CGMutablePathRef path = nullptr);
void setClip(const QRegion *rgn=0); void setClip(const QRegion *rgn = nullptr);
void resetClip(); void resetClip();
void setFillBrush(const QPointF &origin=QPoint()); void setFillBrush(const QPointF &origin=QPoint());
void setStrokePen(const QPen &pen); void setStrokePen(const QPen &pen);
@ -174,7 +174,7 @@ public:
float penOffset(); float penOffset();
QPointF devicePixelSize(CGContextRef context); QPointF devicePixelSize(CGContextRef context);
float adjustPenWidth(float penWidth); float adjustPenWidth(float penWidth);
inline void setTransform(const QTransform *matrix=0) inline void setTransform(const QTransform *matrix = nullptr)
{ {
CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd))); CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
CGAffineTransform xform = orig_xform; CGAffineTransform xform = orig_xform;

View File

@ -117,7 +117,7 @@ bool QMacPrintEngine::end()
if (d->paintEngine->type() == QPaintEngine::CoreGraphics) { if (d->paintEngine->type() == QPaintEngine::CoreGraphics) {
// We don't need the paint engine to call restoreGraphicsState() // We don't need the paint engine to call restoreGraphicsState()
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0; static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0;
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0; static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = nullptr;
} }
d->paintEngine->end(); d->paintEngine->end();
if (d->state != QPrinter::Idle) if (d->state != QPrinter::Idle)
@ -271,7 +271,7 @@ void QMacPrintEnginePrivate::releaseSession()
PMSessionEndPageNoDialog(session()); PMSessionEndPageNoDialog(session());
PMSessionEndDocumentNoDialog(session()); PMSessionEndDocumentNoDialog(session());
[printInfo release]; [printInfo release];
printInfo = 0; printInfo = nil;
} }
bool QMacPrintEnginePrivate::newPage_helper() bool QMacPrintEnginePrivate::newPage_helper()
@ -291,7 +291,7 @@ bool QMacPrintEnginePrivate::newPage_helper()
while (cgEngine->d_func()->stackCount > 0) while (cgEngine->d_func()->stackCount > 0)
cgEngine->d_func()->restoreGraphicsState(); cgEngine->d_func()->restoreGraphicsState();
OSStatus status = PMSessionBeginPageNoDialog(session(), format(), 0); OSStatus status = PMSessionBeginPageNoDialog(session(), format(), nullptr);
if (status != noErr) { if (status != noErr) {
state = QPrinter::Error; state = QPrinter::Error;
return false; return false;
@ -318,7 +318,7 @@ bool QMacPrintEnginePrivate::newPage_helper()
if (m_pageLayout.mode() != QPageLayout::FullPageMode) if (m_pageLayout.mode() != QPageLayout::FullPageMode)
CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y()); CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y());
cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext); cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext);
cgEngine->d_func()->setClip(0); cgEngine->d_func()->setClip(nullptr);
cgEngine->state->dirtyFlags = QPaintEngine::DirtyFlag(QPaintEngine::AllDirty cgEngine->state->dirtyFlags = QPaintEngine::DirtyFlag(QPaintEngine::AllDirty
& ~(QPaintEngine::DirtyClipEnabled & ~(QPaintEngine::DirtyClipEnabled
| QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipRegion
@ -340,7 +340,7 @@ void QMacPrintEnginePrivate::setPageSize(const QPageSize &pageSize)
// Get the PMPaper and check it is valid // Get the PMPaper and check it is valid
PMPaper macPaper = m_printDevice->macPaper(usePageSize); PMPaper macPaper = m_printDevice->macPaper(usePageSize);
if (macPaper == 0) { if (!macPaper) {
qWarning() << "QMacPrintEngine: Invalid PMPaper returned for " << pageSize; qWarning() << "QMacPrintEngine: Invalid PMPaper returned for " << pageSize;
return; return;
} }

View File

@ -134,7 +134,7 @@ public:
QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle), QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle),
m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))), m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))),
printInfo(0), paintEngine(0), embedFonts(true) {} printInfo(nullptr), paintEngine(nullptr), embedFonts(true) {}
~QMacPrintEnginePrivate(); ~QMacPrintEnginePrivate();
void initialize(); void initialize();