QWidget::create(): Mark parameter window as ignored.

Remove parameter from QWidgetPrivate::createWinId(), add a warning and fixme
comments. Update the documentation to point the users to QWindow::fromWinId()
and QWidget::createWindowContainer().

Task-number: QTBUG-33079
Task-number: QTBUG-51853
Change-Id: I03ae922b31bb46a411889cc0260ea14a4d933492
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Friedemann Kleint 2016-03-21 14:17:18 +01:00
parent 8fd96d78f0
commit 663263c124
2 changed files with 15 additions and 17 deletions

View File

@ -1243,11 +1243,14 @@ void QWidgetPrivate::createRecursively()
}
// ### fixme: Qt 6: Remove parameter window from QWidget::create()
/*!
Creates a new widget window if \a window is 0, otherwise sets the
widget's window to \a window.
Creates a new widget window.
The parameter \a window is ignored in Qt 5. Please use
QWindow::fromWinId() to create a QWindow wrapping a foreign
window and pass it to QWidget::createWindowContainer() instead.
Initializes the window (sets the geometry etc.) if \a
initializeWindow is true. If \a initializeWindow is false, no
@ -1260,11 +1263,15 @@ void QWidgetPrivate::createRecursively()
The QWidget constructor calls create(0,true,true) to create a
window for this widget.
\sa createWindowContainer(), QWindow::fromWinId()
*/
void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_D(QWidget);
if (Q_UNLIKELY(window))
qWarning("QWidget::create(): Parameter 'window' does not have any effect.");
if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
return;
@ -1288,7 +1295,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
// We're about to create a native child widget that doesn't have a native parent;
// enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors
// attribute is set.
d->createWinId(window);
d->createWinId();
// Nothing more to do.
Q_ASSERT(testAttribute(Qt::WA_WState_Created));
Q_ASSERT(internalWinId());
@ -2520,13 +2527,12 @@ WId QWidget::winId() const
return data->winid;
}
void QWidgetPrivate::createWinId(WId winid)
void QWidgetPrivate::createWinId()
{
Q_Q(QWidget);
#ifdef ALIEN_DEBUG
qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
qDebug() << "QWidgetPrivate::createWinId for" << q;
#endif
const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
@ -2543,15 +2549,7 @@ void QWidgetPrivate::createWinId(WId winid)
QWidget *w = qobject_cast<QWidget *>(pd->children.at(i));
if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
|| (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
if (w!=q) {
w->create();
} else {
w->create(winid);
// if the window has already been created, we
// need to raise it to its proper stacking position
if (winid)
w->raise();
}
w->create();
}
}
} else {

View File

@ -333,7 +333,7 @@ public:
void init(QWidget *desktopWidget, Qt::WindowFlags f);
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
void createRecursively();
void createWinId(WId id = 0);
void createWinId();
void createTLExtra();
void createExtra();