Android: Initialize window in QPlatformWindow::initialize() override
During the QAndroidPlatformWindow constructor we can't safely call virtual functions of QPlatformWindow and expect them to resolve to subclasses, e.g. QAndroidPlatformForeignWindow. Importantly, this means we can't check isForeignWindow() during construction. QPlatformWindow has a dedicated initialization function for this use-case, so use that instead. The existing order of between QAndroidPlatformForeignWindow and QAndroidPlatformWindow has been kept as is. Change-Id: I2a08326fae6a3b079cd153c50a13794310ac3d74 Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io> (cherry picked from commit 7150c79d0ee10d6aca330e6a0862b0fbfec071fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4c1a82e4cf
commit
c45da998ad
@ -11,9 +11,16 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QAndroidPlatformForeignWindow::QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle)
|
||||
: QAndroidPlatformWindow(window), m_view(nullptr), m_nativeViewInserted(false)
|
||||
: QAndroidPlatformWindow(window)
|
||||
, m_view(reinterpret_cast<jobject>(nativeHandle))
|
||||
, m_nativeViewInserted(false)
|
||||
{
|
||||
m_view = reinterpret_cast<jobject>(nativeHandle);
|
||||
}
|
||||
|
||||
void QAndroidPlatformForeignWindow::initialize()
|
||||
{
|
||||
QAndroidPlatformWindow::initialize();
|
||||
|
||||
if (isEmbeddingContainer()) {
|
||||
m_nativeViewId = m_view.callMethod<jint>("getId");
|
||||
return;
|
||||
|
@ -16,6 +16,7 @@ class QAndroidPlatformForeignWindow : public QAndroidPlatformWindow
|
||||
{
|
||||
public:
|
||||
explicit QAndroidPlatformForeignWindow(QWindow *window, WId nativeHandle);
|
||||
void initialize() override;
|
||||
~QAndroidPlatformForeignWindow();
|
||||
void setGeometry(const QRect &rect) override;
|
||||
void setVisible(bool visible) override;
|
||||
|
@ -25,6 +25,13 @@ QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window)
|
||||
m_surfaceContainerType(SurfaceContainer::TextureView), m_nativeParentQtWindow(nullptr),
|
||||
m_androidSurfaceObject(nullptr)
|
||||
{
|
||||
// Please add any initialization in the function below
|
||||
}
|
||||
|
||||
void QAndroidPlatformWindow::initialize()
|
||||
{
|
||||
QWindow *window = QPlatformWindow::window();
|
||||
|
||||
m_windowFlags = Qt::Widget;
|
||||
m_windowState = Qt::WindowNoState;
|
||||
// the surfaceType is overwritten in QAndroidPlatformOpenGLWindow ctor so let's save
|
||||
|
@ -32,6 +32,8 @@ public:
|
||||
};
|
||||
|
||||
explicit QAndroidPlatformWindow(QWindow *window);
|
||||
void initialize() override;
|
||||
|
||||
~QAndroidPlatformWindow();
|
||||
void lower() override;
|
||||
void raise() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user