core: derive incubation controllers from tracked windows list

Replaces the attempts to track incubation controllers directly with a
list of all known windows, then pulls the first usable incubation
controller when an assignment is requested.

This should finally fix incubation controller related use after free crashes.
This commit is contained in:
outfoxxed 2025-09-19 00:16:26 -07:00
parent 59f5744f30
commit e9a574d919
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 27 additions and 103 deletions

View file

@ -9,6 +9,7 @@
#include <qqmlengine.h>
#include <qqmlerror.h>
#include <qqmlincubator.h>
#include <qquickwindow.h>
#include <qtclasshelpermacros.h>
#include "incubator.hpp"
@ -40,8 +41,7 @@ public:
void setWatchingFiles(bool watching);
bool setExtraWatchedFiles(const QVector<QString>& files);
void registerIncubationController(QQmlIncubationController* controller);
void deregisterIncubationController(QQmlIncubationController* controller);
void trackWindowIncubationController(QQuickWindow* window);
// takes ownership
void registerExtension(const void* key, EngineGenerationExt* extension);
@ -84,13 +84,13 @@ public slots:
private slots:
void onFileChanged(const QString& name);
void onDirectoryChanged();
void incubationControllerDestroyed();
void onTrackedWindowDestroyed(QObject* object);
static void onEngineWarnings(const QList<QQmlError>& warnings);
private:
void postReload();
void assignIncubationController();
QVector<QObject*> incubationControllers;
QVector<QQuickWindow*> trackedWindows;
bool incubationControllersLocked = false;
QHash<const void*, EngineGenerationExt*> extensions;