UI: Don't create obs_display when QTToGSWindow fails
Right after showing the OBSQTDisplay widget, it may happen that a wl_surface is not yet created and attached to the window. When this happens, creating the OBS display results in a crash. Make QTToGSWindow return a boolean, indicating success or failure, and don't create the OBS display on failure.
This commit is contained in:
parent
60dab2cf1c
commit
b71498e8ab
@ -100,7 +100,8 @@ void OBSQTDisplay::CreateDisplay()
|
||||
info.format = GS_BGRA;
|
||||
info.zsformat = GS_ZS_NONE;
|
||||
|
||||
QTToGSWindow(windowHandle(), info.window);
|
||||
if (!QTToGSWindow(windowHandle(), info.window))
|
||||
return;
|
||||
|
||||
display = obs_display_create(&info, backgroundColor);
|
||||
|
||||
|
@ -113,8 +113,10 @@ void OBSMessageBox::critical(QWidget *parent, const QString &title,
|
||||
mb.exec();
|
||||
}
|
||||
|
||||
void QTToGSWindow(QWindow *window, gs_window &gswindow)
|
||||
bool QTToGSWindow(QWindow *window, gs_window &gswindow)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
gswindow.hwnd = (HWND)window->winId();
|
||||
#elif __APPLE__
|
||||
@ -132,10 +134,12 @@ void QTToGSWindow(QWindow *window, gs_window &gswindow)
|
||||
QGuiApplication::platformNativeInterface();
|
||||
gswindow.display =
|
||||
native->nativeResourceForWindow("surface", window);
|
||||
success = gswindow.display != nullptr;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods)
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
void OBSErrorBox(QWidget *parent, const char *msg, ...);
|
||||
|
||||
void QTToGSWindow(QWindow *window, gs_window &gswindow);
|
||||
bool QTToGSWindow(QWindow *window, gs_window &gswindow);
|
||||
|
||||
uint32_t TranslateQtKeyboardEventModifiers(Qt::KeyboardModifiers mods);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user