Compare commits
3 commits
7feae55ebe
...
d56c07ceb3
Author | SHA1 | Date | |
---|---|---|---|
outfoxxed | d56c07ceb3 | ||
outfoxxed | 84bb4098ad | ||
outfoxxed | 6c9526761c |
|
@ -14,7 +14,6 @@
|
||||||
#include <qqmlcontext.h>
|
#include <qqmlcontext.h>
|
||||||
#include <qqmlengine.h>
|
#include <qqmlengine.h>
|
||||||
#include <qqmlincubator.h>
|
#include <qqmlincubator.h>
|
||||||
#include <qtimer.h>
|
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
#include "iconimageprovider.hpp"
|
#include "iconimageprovider.hpp"
|
||||||
|
@ -47,32 +46,30 @@ EngineGeneration::EngineGeneration(const QDir& rootPath, QmlScanner scanner)
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineGeneration::~EngineGeneration() {
|
EngineGeneration::~EngineGeneration() {
|
||||||
g_generations.remove(this->engine);
|
if (this->engine != nullptr) {
|
||||||
delete this->engine;
|
qFatal() << this << "destroyed without calling destroy()";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineGeneration::destroy() {
|
void EngineGeneration::destroy() {
|
||||||
// Multiple generations can detect a reload at the same time.
|
// Multiple generations can detect a reload at the same time.
|
||||||
delete this->watcher;
|
QObject::disconnect(this->watcher, nullptr, this, nullptr);
|
||||||
|
this->watcher->deleteLater();
|
||||||
this->watcher = nullptr;
|
this->watcher = nullptr;
|
||||||
|
|
||||||
// Yes all of this is actually necessary.
|
|
||||||
if (this->engine != nullptr && this->root != nullptr) {
|
if (this->engine != nullptr && this->root != nullptr) {
|
||||||
QObject::connect(this->root, &QObject::destroyed, this, [this]() {
|
QObject::connect(this->root, &QObject::destroyed, this, [this]() {
|
||||||
// The timer seems to fix *one* of the possible qml item destructor crashes.
|
// prevent further js execution between garbage collection and engine destruction.
|
||||||
QTimer::singleShot(0, [this]() {
|
this->engine->setInterrupted(true);
|
||||||
// Garbage is not collected during engine destruction.
|
|
||||||
this->engine->collectGarbage();
|
|
||||||
|
|
||||||
QObject::connect(this->engine, &QObject::destroyed, this, [this]() { delete this; });
|
g_generations.remove(this->engine);
|
||||||
|
|
||||||
// Even after all of that there's still multiple failing assertions and segfaults.
|
// Garbage is not collected during engine destruction.
|
||||||
// Pray you don't hit one.
|
this->engine->collectGarbage();
|
||||||
// Note: it appeats *some* of the crashes are related to values owned by the generation.
|
|
||||||
// Test by commenting the connect() above.
|
delete this->engine;
|
||||||
this->engine->deleteLater();
|
this->engine = nullptr;
|
||||||
this->engine = nullptr;
|
delete this;
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this->root->deleteLater();
|
this->root->deleteLater();
|
||||||
|
|
|
@ -65,7 +65,7 @@ void RootWrapper::reloadGraph(bool hard) {
|
||||||
auto* obj = component.beginCreate(generation->engine->rootContext());
|
auto* obj = component.beginCreate(generation->engine->rootContext());
|
||||||
|
|
||||||
if (obj == nullptr) {
|
if (obj == nullptr) {
|
||||||
QString error = "failed to create root component\n" + component.errorString();
|
const QString error = "failed to create root component\n" + component.errorString();
|
||||||
qWarning().noquote() << error;
|
qWarning().noquote() << error;
|
||||||
delete generation;
|
delete generation;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ void RootWrapper::reloadGraph(bool hard) {
|
||||||
|
|
||||||
auto* newRoot = qobject_cast<ShellRoot*>(obj);
|
auto* newRoot = qobject_cast<ShellRoot*>(obj);
|
||||||
if (newRoot == nullptr) {
|
if (newRoot == nullptr) {
|
||||||
QString error = "root component was not a Quickshell.ShellRoot";
|
const QString error = "root component was not a Quickshell.ShellRoot";
|
||||||
qWarning().noquote() << error;
|
qWarning().noquote() << error;
|
||||||
delete obj;
|
delete obj;
|
||||||
delete generation;
|
delete generation;
|
||||||
|
@ -96,7 +96,11 @@ void RootWrapper::reloadGraph(bool hard) {
|
||||||
|
|
||||||
auto isReload = this->generation != nullptr;
|
auto isReload = this->generation != nullptr;
|
||||||
generation->onReload(hard ? nullptr : this->generation);
|
generation->onReload(hard ? nullptr : this->generation);
|
||||||
if (hard) delete this->generation;
|
|
||||||
|
if (hard && this->generation != nullptr) {
|
||||||
|
this->generation->destroy();
|
||||||
|
}
|
||||||
|
|
||||||
this->generation = generation;
|
this->generation = generation;
|
||||||
|
|
||||||
qInfo() << "Configuration Loaded";
|
qInfo() << "Configuration Loaded";
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <private/qwaylandsurface_p.h>
|
#include <private/qwaylandsurface_p.h>
|
||||||
#include <private/qwaylandwindow_p.h>
|
#include <private/qwaylandwindow_p.h>
|
||||||
#include <qlogging.h>
|
#include <qlogging.h>
|
||||||
#include <qpoint.h>
|
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
#include <qsize.h>
|
#include <qsize.h>
|
||||||
#include <qtversionchecks.h>
|
#include <qtversionchecks.h>
|
||||||
|
@ -18,6 +17,10 @@
|
||||||
#include "shell_integration.hpp"
|
#include "shell_integration.hpp"
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||||
|
#include <qpoint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
[[nodiscard]] QtWayland::zwlr_layer_shell_v1::layer toWaylandLayer(const WlrLayer::Enum& layer) noexcept;
|
[[nodiscard]] QtWayland::zwlr_layer_shell_v1::layer toWaylandLayer(const WlrLayer::Enum& layer) noexcept;
|
||||||
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::anchor toWaylandAnchors(const Anchors& anchors) noexcept;
|
[[nodiscard]] QtWayland::zwlr_layer_surface_v1::anchor toWaylandAnchors(const Anchors& anchors) noexcept;
|
||||||
|
@ -72,7 +75,10 @@ QSWaylandLayerSurface::QSWaylandLayerSurface(
|
||||||
}
|
}
|
||||||
|
|
||||||
QSWaylandLayerSurface::~QSWaylandLayerSurface() {
|
QSWaylandLayerSurface::~QSWaylandLayerSurface() {
|
||||||
this->ext->surface = nullptr;
|
if (this->ext != nullptr) {
|
||||||
|
this->ext->surface = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
this->destroy();
|
this->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +112,7 @@ void QSWaylandLayerSurface::applyConfigure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSWaylandLayerSurface::setWindowGeometry(const QRect& geometry) {
|
void QSWaylandLayerSurface::setWindowGeometry(const QRect& geometry) {
|
||||||
|
if (this->ext == nullptr) return;
|
||||||
auto size = constrainedSize(this->ext->mAnchors, geometry.size());
|
auto size = constrainedSize(this->ext->mAnchors, geometry.size());
|
||||||
this->set_size(size.width(), size.height());
|
this->set_size(size.width(), size.height());
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#include "shell_integration.hpp"
|
#include "shell_integration.hpp"
|
||||||
#include "surface.hpp"
|
#include "surface.hpp"
|
||||||
|
|
||||||
|
LayershellWindowExtension::~LayershellWindowExtension() {
|
||||||
|
if (this->surface != nullptr) {
|
||||||
|
this->surface->ext = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LayershellWindowExtension* LayershellWindowExtension::get(QWindow* window) {
|
LayershellWindowExtension* LayershellWindowExtension::get(QWindow* window) {
|
||||||
auto v = window->property("layershell_ext");
|
auto v = window->property("layershell_ext");
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qscreen.h>
|
#include <qscreen.h>
|
||||||
|
#include <qtclasshelpermacros.h>
|
||||||
#include <qtmetamacros.h>
|
#include <qtmetamacros.h>
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
#include <qwindow.h>
|
#include <qwindow.h>
|
||||||
|
@ -56,6 +57,8 @@ class LayershellWindowExtension: public QObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LayershellWindowExtension(QObject* parent = nullptr): QObject(parent) {}
|
LayershellWindowExtension(QObject* parent = nullptr): QObject(parent) {}
|
||||||
|
~LayershellWindowExtension() override;
|
||||||
|
Q_DISABLE_COPY_MOVE(LayershellWindowExtension);
|
||||||
|
|
||||||
// returns the layershell extension if attached, otherwise nullptr
|
// returns the layershell extension if attached, otherwise nullptr
|
||||||
static LayershellWindowExtension* get(QWindow* window);
|
static LayershellWindowExtension* get(QWindow* window);
|
||||||
|
|
Loading…
Reference in a new issue