mirror of
https://github.com/quickshell-mirror/quickshell.git
synced 2026-10-27 02:54:36 +00:00
core/generation: destroy the engine after the root's children
This commit is contained in:
1 parent
25da30db02
commit
4594680eb4
2 files changed
+28
-15
No files matched your search
@@ -11,3 +11,4 @@
|
||||
- Fixed `WlSessionLockSurface.screen` being null and never updating with a real screen on monitor plug.
|
||||
- Fixed `NotificationAction.text` not accepting text updates.
|
||||
- Fixed PipeWire route volume writes for devices without a reported volume step.
|
||||
- Fixed a crash when quitting or reloading while a `Loader` was still loading asynchronously.
|
||||
+27
-15
@@ -11,6 +11,7 @@
|
||||
#include <qlist.h>
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlcontext.h>
|
||||
#include <qqmlengine.h>
|
||||
@@ -83,25 +84,36 @@ void EngineGeneration::destroy() {
|
||||
}
|
||||
|
||||
if (this->root != nullptr) {
|
||||
// prevent further js execution during teardown of the root's children, gc and the engine.
|
||||
QObject::connect(this->root, &QObject::destroyed, this, [this]() {
|
||||
// prevent further js execution between garbage collection and engine destruction.
|
||||
this->engine->setInterrupted(true);
|
||||
|
||||
g_generations.remove(this->engine);
|
||||
|
||||
// Garbage is not collected during engine destruction.
|
||||
this->engine->collectGarbage();
|
||||
|
||||
delete this->engine;
|
||||
this->engine = nullptr;
|
||||
|
||||
auto terminate = this->shouldTerminate;
|
||||
auto code = this->exitCode;
|
||||
delete this;
|
||||
|
||||
if (terminate) QCoreApplication::exit(code);
|
||||
});
|
||||
|
||||
// QObject::destroyed is emitted before the root's children are destroyed.
|
||||
// The engine must outlive them, as objects such as Loaders with in-flight
|
||||
// incubations access it in their destructors.
|
||||
QObject::connect(
|
||||
this->root,
|
||||
&QObject::destroyed,
|
||||
this,
|
||||
[this]() {
|
||||
g_generations.remove(this->engine);
|
||||
|
||||
// Garbage is not collected during engine destruction.
|
||||
this->engine->collectGarbage();
|
||||
|
||||
delete this->engine;
|
||||
this->engine = nullptr;
|
||||
|
||||
auto terminate = this->shouldTerminate;
|
||||
auto code = this->exitCode;
|
||||
delete this;
|
||||
|
||||
if (terminate) QCoreApplication::exit(code);
|
||||
},
|
||||
Qt::QueuedConnection
|
||||
);
|
||||
|
||||
this->root->deleteLater();
|
||||
this->root = nullptr;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user