Skip to content

Commit 6e7dfb7

Browse files
committed
Always throw when registering existing prototype.
Remove checks for equal object type. This allows to correctly handle Python-derived classes, which appeared as the same type in C++.
1 parent 0463c78 commit 6e7dfb7

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

src/diffpy/HasClassRegistry.ipp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ bool HasClassRegistry<TBase>::registerThisType() const
3535
RegistryStorage& reg = getRegistry();
3636
if (reg.count(this->type()))
3737
{
38-
// do nothing when registering the same class twice
39-
const TBase& regprot = *(reg[this->type()]);
40-
if (typeid(*this) == typeid(regprot)) return true;
4138
// raise exception if trying to register a different class
4239
ostringstream emsg;
4340
emsg << "Prototype type '" << this->type() <<

src/tests/TestHasClassRegistry.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class TestHasClassRegistry : public CxxTest::TestSuite
4646
void tearDown()
4747
{
4848
// restore SFTXray registration if removed in some test.
49+
msftb->deregisterType(msftb->type());
4950
msftb->registerThisType();
5051
TS_ASSERT(ScatteringFactorTable::isRegisteredType("X"));
5152
TS_ASSERT(ScatteringFactorTable::isRegisteredType("xray"));

0 commit comments

Comments
 (0)