Why this complex flow? :-)

~~~
if(mActiveRepo)
    emit repositoryDeactivated(mActiveRepo);
mActiveRepo = repository;
if(mActiveRepo) /* Omitting this was a design mistake along not creating a 'deactivate' in the first place */
    emit repositoryActivated(mActiveRepo);
~~~