Segfault when calling destructor on ctkDICOMIndexer and ctkDICOMDatabase

I am working on a loadable module extension in which I create a new ctkDICOMIndexer object and a new ctkDICOMDatabase, which I delete in the extension’s destructor. However, when I quit my application, a segfault occurs. I’ve identified that it occurs in the file ctkDICOMIndexer.cpp file in the line “QObject::disconnect(d->Database, SIGNAL(opened()), this, SLOT(databaseFilenameChanged()));”
Does anyone know what the problem could be?

Probably when you deleted the database then you forget to set d->Database to nullptr. Dereferencing a dangling pointer (using then d->Database after the object is deleted) will cause a segfault. The solution is to set the pointer to nullptr (or use some type of smart pointer) and only disconnect the database if it still exists.