wasm: always call destroy() before deleting a screen
QWasmCompositor currently has the requirement that destroying it requires freeing a GL texture, which requires a valid GL context, which requires a valid screen, in order to get to the native context on the canvas. For this reason QWasmScreen has a destroy() function which is called before deleting the QScreen and QPlatformScreen. Make sure we call destroy() also when deleting all screens in the QWasmIntegration destructor. Move the common logic into a new deleteScreen() function which replaces destroy(). Change-Id: I628f13c868808db539effff9b29ecbefac23abc9 Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>bb10
parent
b119f26a56
commit
83106badcd
|
|
@ -196,7 +196,8 @@ QWasmIntegration::~QWasmIntegration()
|
|||
delete m_drag;
|
||||
|
||||
for (const auto &elementAndScreen : m_screens)
|
||||
QWindowSystemInterface::handleScreenRemoved(elementAndScreen.second);
|
||||
elementAndScreen.second->deleteScreen();
|
||||
|
||||
m_screens.clear();
|
||||
|
||||
s_instance = nullptr;
|
||||
|
|
@ -338,10 +339,7 @@ void QWasmIntegration::removeScreen(const emscripten::val &element)
|
|||
qWarning() << "Attempting to remove non-existing screen for element" << QWasmString::toQString(element["id"]);;
|
||||
return;
|
||||
}
|
||||
QWasmScreen *exScreen = it->second;
|
||||
m_screens.erase(it);
|
||||
exScreen->destroy(); // clean up before deleting the screen
|
||||
QWindowSystemInterface::handleScreenRemoved(exScreen);
|
||||
it->second->deleteScreen();
|
||||
}
|
||||
|
||||
void QWasmIntegration::resizeScreen(const emscripten::val &element)
|
||||
|
|
|
|||
|
|
@ -131,9 +131,10 @@ QWasmScreen::~QWasmScreen()
|
|||
m_canvas.set(m_canvasResizeObserverCallbackContextPropertyName, emscripten::val(intptr_t(0)));
|
||||
}
|
||||
|
||||
void QWasmScreen::destroy()
|
||||
void QWasmScreen::deleteScreen()
|
||||
{
|
||||
m_compositor->destroy();
|
||||
QWindowSystemInterface::handleScreenRemoved(this);
|
||||
}
|
||||
|
||||
QWasmScreen *QWasmScreen::get(QPlatformScreen *screen)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class QWasmScreen : public QObject, public QPlatformScreen
|
|||
public:
|
||||
QWasmScreen(const emscripten::val &containerOrCanvas);
|
||||
~QWasmScreen();
|
||||
void destroy();
|
||||
void deleteScreen();
|
||||
|
||||
static QWasmScreen *get(QPlatformScreen *screen);
|
||||
static QWasmScreen *get(QScreen *screen);
|
||||
|
|
|
|||
Loading…
Reference in New Issue