2020-09-01 10:47:53 +00:00
|
|
|
From 334bad8172f854d14e3079f03349d16a4ce2df73 Mon Sep 17 00:00:00 2001
|
2020-08-19 07:53:02 +00:00
|
|
|
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
|
|
|
Date: Tue, 18 Aug 2020 19:38:29 -0300
|
2020-09-01 10:47:53 +00:00
|
|
|
Subject: [PATCH 15/24] UI: Destroy display when becoming invisible
|
2020-08-19 07:53:02 +00:00
|
|
|
|
|
|
|
When a window is made invisible, then visible again, the
|
|
|
|
obs_display is reused. Turns out, QT destroys the wl_surface
|
|
|
|
associated with the previewer on Wayland. However, the EGL
|
|
|
|
surface created on top of this wl_surface is not, and any
|
|
|
|
attempt to attach a new buffer to it will crash OBS.
|
|
|
|
|
|
|
|
Destroy the obs_display when becoming invisible, and when
|
2020-08-23 10:56:49 +00:00
|
|
|
running as a Wayland client. Also nullify the display
|
|
|
|
variable on destruction, to avoid subclasses double-freeing
|
|
|
|
the obs display.
|
2020-08-19 07:53:02 +00:00
|
|
|
---
|
|
|
|
UI/qt-display.cpp | 13 ++++++++++++-
|
2020-08-23 10:56:49 +00:00
|
|
|
UI/qt-display.hpp | 1 +
|
|
|
|
2 files changed, 13 insertions(+), 1 deletion(-)
|
2020-08-19 07:53:02 +00:00
|
|
|
|
|
|
|
diff --git a/UI/qt-display.cpp b/UI/qt-display.cpp
|
|
|
|
index 685ee6f9..fc83e0e0 100644
|
|
|
|
--- a/UI/qt-display.cpp
|
|
|
|
+++ b/UI/qt-display.cpp
|
|
|
|
@@ -6,6 +6,12 @@
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QShowEvent>
|
|
|
|
|
|
|
|
+#include <obs-config.h>
|
|
|
|
+
|
|
|
|
+#ifdef ENABLE_WAYLAND
|
|
|
|
+#include <obs-nix-platform.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
static inline long long color_to_int(const QColor &color)
|
|
|
|
{
|
|
|
|
auto shift = [&](unsigned val, int shift) {
|
|
|
|
@@ -33,8 +39,13 @@ OBSQTDisplay::OBSQTDisplay(QWidget *parent, Qt::WindowFlags flags)
|
|
|
|
setAttribute(Qt::WA_NativeWindow);
|
|
|
|
|
|
|
|
auto windowVisible = [this](bool visible) {
|
|
|
|
- if (!visible)
|
|
|
|
+ if (!visible) {
|
|
|
|
+#ifdef ENABLE_WAYLAND
|
|
|
|
+ if (obs_get_nix_platform() == OBS_NIX_PLATFORM_WAYLAND)
|
|
|
|
+ display = nullptr;
|
|
|
|
+#endif
|
|
|
|
return;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (!display) {
|
|
|
|
CreateDisplay();
|
2020-08-23 10:56:49 +00:00
|
|
|
diff --git a/UI/qt-display.hpp b/UI/qt-display.hpp
|
|
|
|
index a2e5a3ef..50f891f8 100644
|
|
|
|
--- a/UI/qt-display.hpp
|
|
|
|
+++ b/UI/qt-display.hpp
|
|
|
|
@@ -25,6 +25,7 @@ signals:
|
|
|
|
public:
|
|
|
|
OBSQTDisplay(QWidget *parent = nullptr,
|
|
|
|
Qt::WindowFlags flags = nullptr);
|
|
|
|
+ ~OBSQTDisplay() { display = nullptr; }
|
|
|
|
|
|
|
|
virtual QPaintEngine *paintEngine() const override;
|
|
|
|
|
2020-08-19 07:53:02 +00:00
|
|
|
--
|
|
|
|
2.28.0
|
|
|
|
|