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

actorid
Jan Borsodi 14 years ago
parent 16aa13721a
commit 506f61d254

@ -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;

@ -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

Loading…
Cancel
Save