Another use of a slot to fix c++ objected deleted error