fix connect to destroyed, should solve crashes
This commit is contained in:
parent
5b452bfb9a
commit
58d281d0b9
@ -147,7 +147,11 @@ void FullScreenWindow::init(const QString &componentName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDeclarativeEngine *engine = EngineBookKeeping::self()->engineFor(this);
|
QDeclarativeEngine *engine = EngineBookKeeping::self()->engine();
|
||||||
|
if (!engine) {
|
||||||
|
kWarning() << "Warning, no QDeclarativeEngines available anymore, should never happen";
|
||||||
|
Q_ASSERT(0);
|
||||||
|
}
|
||||||
QDeclarativeComponent *component = new QDeclarativeComponent(engine, filePath, this);
|
QDeclarativeComponent *component = new QDeclarativeComponent(engine, filePath, this);
|
||||||
|
|
||||||
QDeclarativeContext *creationContext = component->creationContext();
|
QDeclarativeContext *creationContext = component->creationContext();
|
||||||
|
@ -54,28 +54,21 @@ EngineBookKeeping *EngineBookKeeping::self()
|
|||||||
return &privateBKSelf->self;
|
return &privateBKSelf->self;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDeclarativeEngine *EngineBookKeeping::engineFor(QObject *item) const
|
QDeclarativeEngine *EngineBookKeeping::engine() const
|
||||||
{
|
{
|
||||||
//for components creation, any engine will do, as long is valid
|
//for components creation, any engine will do, as long is valid
|
||||||
return m_engines.values().first();
|
if (m_engines.isEmpty()) {
|
||||||
/*
|
kWarning() << "No engines found, this should never happen";
|
||||||
foreach (QDeclarativeEngine *engine, m_engines) {
|
return 0;
|
||||||
QObject *root = engine->rootContext()->contextObject();
|
} else {
|
||||||
QObject *candidate = item;
|
return m_engines.values().first();
|
||||||
|
|
||||||
while (candidate) {
|
|
||||||
if (candidate == root) {
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
candidate = candidate->parent();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EngineBookKeeping::insertEngine(QDeclarativeEngine *engine)
|
void EngineBookKeeping::insertEngine(QDeclarativeEngine *engine)
|
||||||
{
|
{
|
||||||
connect(engine, SIGNAL(destroyed(QObject *)), this, SLOT(engineDestroyed(QObject *deleted)));
|
connect(engine, SIGNAL(destroyed(QObject *)),
|
||||||
|
this, SLOT(engineDestroyed(QObject *)));
|
||||||
m_engines.insert(engine);
|
m_engines.insert(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
static EngineBookKeeping *self();
|
static EngineBookKeeping *self();
|
||||||
|
|
||||||
void insertEngine(QDeclarativeEngine *engine);
|
void insertEngine(QDeclarativeEngine *engine);
|
||||||
QDeclarativeEngine *engineFor(QObject *item) const;
|
QDeclarativeEngine *engine() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void engineDestroyed(QObject *deleted);
|
void engineDestroyed(QObject *deleted);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user