Set paneltoolbox properties on construction
Also refactor the code to avoid creating and deleting an object if containmentGraphicObject does not exist.
This commit is contained in:
parent
233267f492
commit
39ce54c0db
@ -121,18 +121,16 @@ void ContainmentInterface::init()
|
||||
}
|
||||
|
||||
if (pkg.isValid()) {
|
||||
QObject *toolBoxObject = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")));
|
||||
|
||||
QObject *containmentGraphicObject = qmlObject()->rootObject();
|
||||
|
||||
if (containmentGraphicObject && toolBoxObject) {
|
||||
toolBoxObject->setProperty("parent", QVariant::fromValue(containmentGraphicObject));
|
||||
|
||||
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject));
|
||||
} else {
|
||||
delete toolBoxObject;
|
||||
if (containmentGraphicObject) {
|
||||
QVariantHash toolboxProperties;
|
||||
toolboxProperties["parent"] = QVariant::fromValue(containmentGraphicObject);
|
||||
QObject *toolBoxObject = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")), toolboxProperties);
|
||||
if (toolBoxObject) {
|
||||
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject));
|
||||
}
|
||||
qDebug() << "Loaded toolbox package" << pkg.path();
|
||||
}
|
||||
qDebug() << "Loaded toolbox package" << pkg.path();
|
||||
} else {
|
||||
qWarning() << "Could not load toolbox package." << pkg.path();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user