forked from quickshell/quickshell
wayland/layershell: ensure bridge is nulled on layer destruction
Fixes rare race condition crashes.
This commit is contained in:
parent
2bcd9e07fd
commit
bf235d3d4d
3 changed files with 34 additions and 3 deletions
|
@ -173,7 +173,10 @@ LayerSurface::LayerSurface(LayerShellIntegration* shell, QtWaylandClient::QWayla
|
||||||
this->bridge->surface = this;
|
this->bridge->surface = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerSurface::~LayerSurface() { this->destroy(); }
|
LayerSurface::~LayerSurface() {
|
||||||
|
delete this->bridge;
|
||||||
|
this->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
void LayerSurface::zwlr_layer_surface_v1_configure(quint32 serial, quint32 width, quint32 height) {
|
void LayerSurface::zwlr_layer_surface_v1_configure(quint32 serial, quint32 width, quint32 height) {
|
||||||
this->ack_configure(serial);
|
this->ack_configure(serial);
|
||||||
|
|
|
@ -34,7 +34,8 @@ ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) {
|
||||||
auto* window = old == nullptr ? nullptr : old->disownWindow();
|
auto* window = old == nullptr ? nullptr : old->disownWindow();
|
||||||
|
|
||||||
if (window != nullptr) {
|
if (window != nullptr) {
|
||||||
this->bridge = LayerSurfaceBridge::init(window, this->computeState());
|
this->connectBridge(LayerSurfaceBridge::init(window, this->computeState()));
|
||||||
|
|
||||||
if (this->bridge) {
|
if (this->bridge) {
|
||||||
return window;
|
return window;
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,7 +49,7 @@ ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) {
|
||||||
ProxiedWindow* WlrLayershell::createQQuickWindow() {
|
ProxiedWindow* WlrLayershell::createQQuickWindow() {
|
||||||
auto* window = this->ProxyWindowBase::createQQuickWindow();
|
auto* window = this->ProxyWindowBase::createQQuickWindow();
|
||||||
|
|
||||||
this->bridge = LayerSurfaceBridge::init(window, this->computeState());
|
this->connectBridge(LayerSurfaceBridge::init(window, this->computeState()));
|
||||||
if (!this->bridge) {
|
if (!this->bridge) {
|
||||||
qWarning() << "Could not attach Layershell extension to new QQuickWindow. Layer will not "
|
qWarning() << "Could not attach Layershell extension to new QQuickWindow. Layer will not "
|
||||||
"behave correctly.";
|
"behave correctly.";
|
||||||
|
@ -72,6 +73,30 @@ void WlrLayershell::connectWindow() {
|
||||||
this->updateAutoExclusion();
|
this->updateAutoExclusion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProxiedWindow* WlrLayershell::disownWindow(bool keepItemOwnership) {
|
||||||
|
auto* window = this->ProxyWindowBase::disownWindow(keepItemOwnership);
|
||||||
|
|
||||||
|
if (this->bridge) {
|
||||||
|
this->connectBridge(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlrLayershell::connectBridge(LayerSurfaceBridge* bridge) {
|
||||||
|
if (this->bridge) {
|
||||||
|
QObject::disconnect(this->bridge, nullptr, this, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->bridge = bridge;
|
||||||
|
|
||||||
|
if (bridge) {
|
||||||
|
QObject::connect(this->bridge, &QObject::destroyed, this, &WlrLayershell::onBridgeDestroyed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WlrLayershell::onBridgeDestroyed() { this->bridge = nullptr; }
|
||||||
|
|
||||||
bool WlrLayershell::deleteOnInvisible() const {
|
bool WlrLayershell::deleteOnInvisible() const {
|
||||||
// Qt windows behave weirdly when geometry is modified and setVisible(false)
|
// Qt windows behave weirdly when geometry is modified and setVisible(false)
|
||||||
// is subsequently called in the same frame.
|
// is subsequently called in the same frame.
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
ProxiedWindow* retrieveWindow(QObject* oldInstance) override;
|
ProxiedWindow* retrieveWindow(QObject* oldInstance) override;
|
||||||
ProxiedWindow* createQQuickWindow() override;
|
ProxiedWindow* createQQuickWindow() override;
|
||||||
void connectWindow() override;
|
void connectWindow() override;
|
||||||
|
ProxiedWindow* disownWindow(bool keepItemOwnership = false) override;
|
||||||
[[nodiscard]] bool deleteOnInvisible() const override;
|
[[nodiscard]] bool deleteOnInvisible() const override;
|
||||||
|
|
||||||
void onPolished() override;
|
void onPolished() override;
|
||||||
|
@ -175,10 +176,12 @@ signals:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateAutoExclusion();
|
void updateAutoExclusion();
|
||||||
|
void onBridgeDestroyed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
[[nodiscard]] LayerSurfaceState computeState() const;
|
[[nodiscard]] LayerSurfaceState computeState() const;
|
||||||
|
|
||||||
|
void connectBridge(LayerSurfaceBridge* bridge);
|
||||||
void onStateChanged();
|
void onStateChanged();
|
||||||
|
|
||||||
bool compositorPicksScreen = true;
|
bool compositorPicksScreen = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue