When the program is closed from outside (regardless as application or plugin) the current modal stack is deleted, but not its containing components which are marked as “autoDelete”, especially problematic with currently active AltertWindow::showMessageBoxAsync. The result is, non deleted windows which are attached to the desktop before the app is finished.
ModalComponentManager::~ModalComponentManager()
{
// add from here
for (int i = stack.size(); --i >= 0;)
{
auto* item = stack.getUnchecked(i);
std::unique_ptr<ModalItem> deleter(stack.removeAndReturn(i));
Component::SafePointer<Component> compToDelete(item->autoDelete ? item->component : nullptr);
compToDelete.deleteAndZero();
}
// until here
stack.clear();
clearSingletonInstance();
}