use a shared pointer for more elegant cleanup at assignment conclusion
Merge pull request #2569 from ddobrev/19520

Restored code that Git had somehow deleted
Merge pull request #2570 from birarda/shared-assignment-pointer

use a QSharedPointer to allow for more elegant assignment cleanup