Core: In dialog to add property only list types that can be instantiated
Fixes #15159: Dialog for adding properties allows property types that give exceptions
This commit is contained in:
@@ -54,9 +54,15 @@ DlgAddProperty::DlgAddProperty(QWidget* parent,
|
||||
if(defType.isBad())
|
||||
defType = App::PropertyString::getClassTypeId();
|
||||
|
||||
std::vector<Base::Type> proptypes;
|
||||
std::vector<Base::Type> types;
|
||||
Base::Type::getAllDerivedFrom(Base::Type::fromName("App::Property"),types);
|
||||
std::sort(types.begin(), types.end(), [](Base::Type a, Base::Type b) { return strcmp(a.getName(), b.getName()) < 0; });
|
||||
Base::Type::getAllDerivedFrom(Base::Type::fromName("App::Property"), proptypes);
|
||||
std::copy_if (proptypes.begin(), proptypes.end(), std::back_inserter(types), [](const Base::Type& type) {
|
||||
return type.canInstantiate();
|
||||
});
|
||||
std::sort(types.begin(), types.end(), [](Base::Type a, Base::Type b) {
|
||||
return strcmp(a.getName(), b.getName()) < 0;
|
||||
});
|
||||
|
||||
for(const auto& type : types) {
|
||||
ui->comboType->addItem(QString::fromLatin1(type.getName()));
|
||||
|
||||
Reference in New Issue
Block a user