Qt4/Qt5 neutral changes:

+ change inheritance of PropertyItem to not derive from BaseClass (and QObject) any more to fix crashes with Qt5
This commit is contained in:
wmayer
2016-12-12 17:01:26 +01:00
parent 8b51a04943
commit b2487828f0
9 changed files with 136 additions and 78 deletions

View File

@@ -239,18 +239,12 @@ void PropertyModel::buildUp(const PropertyModel::PropertyList& props)
App::Property* prop = it->front();
QString editor = QString::fromLatin1(prop->getEditorName());
if (!editor.isEmpty()) {
Base::BaseClass* item = 0;
try {
item = static_cast<Base::BaseClass*>(Base::Type::
createInstanceByName(prop->getEditorName(),true));
}
catch (...) {
}
PropertyItem* item = PropertyItemFactory::instance().createPropertyItem(prop->getEditorName());
if (!item) {
qWarning("No property item for type %s found\n", prop->getEditorName());
continue;
}
if (item->getTypeId().isDerivedFrom(PropertyItem::getClassTypeId())) {
else {
PropertyItem* child = (PropertyItem*)item;
child->setParent(rootItem);
rootItem->appendChild(child);
@@ -286,17 +280,11 @@ void PropertyModel::appendProperty(const App::Property& prop)
{
QString editor = QString::fromLatin1(prop.getEditorName());
if (!editor.isEmpty()) {
Base::BaseClass* item = 0;
try {
item = static_cast<Base::BaseClass*>(Base::Type::
createInstanceByName(prop.getEditorName(),true));
}
catch (...) {
}
PropertyItem* item = PropertyItemFactory::instance().createPropertyItem(prop.getEditorName());
if (!item) {
qWarning("No property item for type %s found\n", prop.getEditorName());
}
else if (item->getTypeId().isDerivedFrom(PropertyItem::getClassTypeId())) {
else {
// notify system to add new row
int row = rootItem->childCount();
beginInsertRows(QModelIndex(), row, row);