1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-13 12:40:04 +00:00

Added a method to remove a dialog safely, first hides the dialog then schedules for deletion in the garbage list.

This commit is contained in:
Jan Borsodi 2010-10-22 23:14:21 +02:00
parent 16aa13721a
commit 506f61d254
2 changed files with 25 additions and 0 deletions

View File

@ -459,6 +459,15 @@ void WindowManager::updateSkillArea()
stats->updateSkillArea();
}
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
{
assert(dialog);
if (!dialog)
return;
dialog->setVisible(false);
garbageDialogs.push_back(dialog);
}
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
{
std::cout << "message box: " << message << std::endl;

View File

@ -228,6 +228,13 @@ namespace MWGui
void updateSkillArea();
///< update display of skills, factions, birth sign, reputation and bounty
template<typename T>
void removeDialog(T*& dialog);
///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr.
void removeDialog(OEngine::GUI::Layout* dialog);
///< Hides dialog and schedules dialog to be deleted.
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
/**
@ -275,5 +282,14 @@ namespace MWGui
void onReviewDialogDone();
void onReviewDialogBack();
};
template<typename T>
void WindowManager::removeDialog(T*& dialog)
{
OEngine::GUI::Layout *d = static_cast<OEngine::GUI::Layout*>(dialog);
removeDialog(d);
dialog = nullptr;
}
}
#endif