Fix memleaks in tst_QStateMachine::eventClassesExported


Wrap the created objects into std::unique_ptr, so that they are
properly removed.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Iafeb04034b9c8109f2a1cb112e889211a6ac2e68
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commita98d9a716a60406fcd356a18ffcaeae63b476645
parentd86fa5e76b2f13633bc557579bde5f0dcc36ab76
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeWed, 4 Oct 2023 15:38:02 +0200