diff --git a/Framework/Kernel/src/PropertyManager.cpp b/Framework/Kernel/src/PropertyManager.cpp index 5026b4cebb1effae6e2cd396c6849bafbc0a417e..710c11d7b9441f60fd0280e4c3e8db8f825b80b8 100644 --- a/Framework/Kernel/src/PropertyManager.cpp +++ b/Framework/Kernel/src/PropertyManager.cpp @@ -501,8 +501,11 @@ std::string PropertyManager::asString(bool withDefaultValues) const { const size_t count = propertyCount(); for (size_t i = 0; i < count; ++i) { Property *p = getPointerToPropertyOrdinal(static_cast<int>(i)); - if (p->isValueSerializable() && (withDefaultValues || !p->isDefault()) && - p->getSettings()->isEnabled(this)) { + bool is_enabled = true; + if (p->getSettings()) { + is_enabled = p->getSettings()->isEnabled(this); + } + if (p->isValueSerializable() && (withDefaultValues || !p->isDefault()) && is_enabled) { jsonMap[p->name()] = p->value(); } } diff --git a/Framework/Kernel/test/PropertyManagerTest.h b/Framework/Kernel/test/PropertyManagerTest.h index 54d99eb676d71b3aaa1bfd128c1638719f166112..5910d915fed2556f12ee48f8265e095741615ef2 100644 --- a/Framework/Kernel/test/PropertyManagerTest.h +++ b/Framework/Kernel/test/PropertyManagerTest.h @@ -401,17 +401,17 @@ public: void test_asStringWithNotEnabledProperty() { PropertyManagerHelper mgr; - TS_ASSERT_THROWS_NOTHING(mgr.declareProperty("Prop1", 42)); - TS_ASSERT_THROWS_NOTHING(mgr.declareProperty("Prop2", true)); + TS_ASSERT_THROWS_NOTHING(mgr.declareProperty("Semaphor", true)); + TS_ASSERT_THROWS_NOTHING(mgr.declareProperty("Crossing", 42)); mgr.setPropertySettings( - "Prop1", make_unique<EnabledWhenProperty>( - "Prop2", Mantid::Kernel::ePropertyCriterion::IS_DEFAULT)); + "Crossing", make_unique<EnabledWhenProperty>( + "Semaphor", Mantid::Kernel::ePropertyCriterion::IS_DEFAULT)); TSM_ASSERT_EQUALS("Show the default", mgr.asString(true), - "{\"Prop1\":\"42\",\"Prop2\":\"1\"}\n"); - mgr.setProperty("Prop2", false); + "{\"Crossing\":\"42\",\"Semaphor\":\"1\"}\n"); + mgr.setProperty("Semaphor", false); TSM_ASSERT_EQUALS("Hide not enabled", mgr.asString(true), - "{\"Prop2\":\"0\"}\n"); + "{\"Semaphor\":\"0\"}\n"); } void test_asString() {