UI: IocContainer: Tear down in reverse order of setup

This commit is contained in:
Nodir Temirkhodjaev 2024-02-11 12:31:26 +03:00
parent 22e50a03b8
commit 8d0e946309
2 changed files with 6 additions and 2 deletions

View File

@ -44,8 +44,9 @@ void IocContainer::setUpAll()
void IocContainer::tearDownAll()
{
for (int i = 0; i < m_size; ++i) {
tearDown(i);
int i = m_setupIndex;
while (--i >= 0) {
tearDown(m_objectSetupIds[i]);
}
}
@ -63,6 +64,7 @@ IocService *IocContainer::setUp(int typeId)
const quint8 flags = m_objectFlags[typeId];
if ((flags & (IsService | WasSetUp)) == IsService) {
m_objectFlags[typeId] = (flags | WasSetUp);
m_objectSetupIds[m_setupIndex++] = typeId;
obj->setUp();
}

View File

@ -109,8 +109,10 @@ private:
static ThreadStorage g_threadStorage;
int m_size = 0;
int m_setupIndex = 0;
quint8 m_objectFlags[IOC_MAX_SIZE] = {};
quint16 m_objectSetupIds[IOC_MAX_SIZE] = {};
IocObject *m_objects[IOC_MAX_SIZE] = {};
};