QCocoaWindow: Fix 10.10 sheet API deprecation warning

'beginSheet:modalForWindow:modalDelegate:didEndSelector:
contextInfo:' is deprecated: first deprecated in macOS
10.10 - Use -[NSWindow beginSheet:completionHandler:]
instead [-Wdeprecated-declarations]

Similarly, although it won't emit any warning, we replace
the usage of -[NSApplication endSheet:] wit -[NSWindow
endSheet:].

Change-Id: Iae71247f818b7183d09c6831fa4cb1b71a54a87a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Gabriel de Dietrich 2017-01-09 12:39:05 -08:00 committed by Jake Petroules
parent 2b928ef6f9
commit a50ed8685f

View File

@ -735,7 +735,7 @@ void QCocoaWindow::setVisible(bool visible)
|| window()->type() == Qt::Sheet)
&& parentCocoaWindow) {
// show the window as a sheet
[NSApp beginSheet:m_nsWindow modalForWindow:parentCocoaWindow->m_nsWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
[parentCocoaWindow->m_nsWindow beginSheet:m_nsWindow completionHandler:nil];
} else if (window()->modality() != Qt::NonModal) {
// show the window as application modal
QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
@ -797,8 +797,10 @@ void QCocoaWindow::setVisible(bool visible)
cocoaEventDispatcherPrivate->endModalSession(window());
m_hasModalSession = false;
} else {
if ([m_nsWindow isSheet])
[NSApp endSheet:m_nsWindow];
if ([m_nsWindow isSheet]) {
Q_ASSERT_X(parentCocoaWindow, "QCocoaWindow", "Window modal dialog has no transient parent.");
[parentCocoaWindow->m_nsWindow endSheet:m_nsWindow];
}
}
hide();