Skip to content

Fix issues with the container used to hold the Profiles in the ProfileManager

Ahmad Samir requested to merge work/ahmad/qsharedptrs into master

I'd used a std::set with a compare function, so that the profiles are always sorted by name ...etc, but that is wrong, as the Key type in the set is a QExplicitlySharedDataPointer, if the QESDP is copied, its own address is going to change, but the address of of the object it's managing (Profile) is the same, that's why QESDP internally overloads operator== to compare the address of its d pointer (the one returned by data()).

That meant that multiple QESDP could exist in the set, not good... (a QSet worked because it uses a hash which is based on the address of the object returned by data()).

So, use a vector, that is sorted by profile name (we only need to sort it when allProfiles() is called, and when a profile name is changed).

This fixes an assert in ProfileManager::setDefaultProfile(); to test open the profile manager and select the built-in profile and click "set default".

Add a unit test.

Edited by Ahmad Samir

Merge request reports