Make fatalMessageBox() end with std::abort() and declare it [[noreturn]]
Many places calling fatalMessageBox() assume it doesn't return, so make it behave this way. See discussion around: https://sourceforge.net/p/flightgear/mailman/message/35766691/ for some context.
This commit is contained in:
parent
5040e6c7f0
commit
9e6a3ebc6b
3 changed files with 16 additions and 12 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <simgear/simgear_config.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MessageBox.hxx"
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
|
@ -146,16 +148,16 @@ MessageBoxResult modalMessageBox(const std::string& caption,
|
|||
#endif
|
||||
}
|
||||
|
||||
MessageBoxResult fatalMessageBox(const std::string& caption,
|
||||
const std::string& msg,
|
||||
const std::string& moreText)
|
||||
[[noreturn]] void fatalMessageBox(const std::string& caption,
|
||||
const std::string& msg,
|
||||
const std::string& moreText)
|
||||
{
|
||||
#if defined(SG_WINDOWS)
|
||||
return win32MessageBox(caption, msg, moreText);
|
||||
win32MessageBox(caption, msg, moreText);
|
||||
#elif defined(SG_MAC)
|
||||
return cocoaFatalMessage(msg, moreText);
|
||||
cocoaFatalMessage(msg, moreText);
|
||||
#elif defined(HAVE_QT)
|
||||
return QtMessageBox(caption, msg, moreText, true);
|
||||
QtMessageBox(caption, msg, moreText, true);
|
||||
#else
|
||||
std::string s = "FATAL: "+ msg;
|
||||
if (!moreText.empty()) {
|
||||
|
@ -169,8 +171,9 @@ MessageBoxResult fatalMessageBox(const std::string& caption,
|
|||
dlg->setStringValue("text/label", s );
|
||||
_gui->showDialog("popup");
|
||||
}
|
||||
return MSG_BOX_OK;
|
||||
#endif
|
||||
|
||||
std::abort();
|
||||
}
|
||||
|
||||
} // of namespace flightgear
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
namespace flightgear
|
||||
{
|
||||
|
||||
enum MessageBoxResult
|
||||
enum MessageBoxResult
|
||||
{
|
||||
MSG_BOX_OK,
|
||||
MSG_BOX_YES,
|
||||
|
@ -17,10 +17,10 @@ MessageBoxResult modalMessageBox(const std::string& caption,
|
|||
const std::string& msg,
|
||||
const std::string& moreText = std::string());
|
||||
|
||||
MessageBoxResult fatalMessageBox(const std::string& caption,
|
||||
[[noreturn]] void fatalMessageBox(const std::string& caption,
|
||||
const std::string& msg,
|
||||
const std::string& moreText = std::string());
|
||||
|
||||
|
||||
} // of namespace flightgear
|
||||
|
||||
#endif // of FG_GUI_MESSAGE_BOX_HXX
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
@ -112,11 +113,11 @@ namespace flightgear
|
|||
return MSG_BOX_OK;
|
||||
}
|
||||
|
||||
MessageBoxResult fatalMessageBox(const std::string& caption,
|
||||
[[noreturn]] void fatalMessageBox(const std::string& caption,
|
||||
const std::string& msg,
|
||||
const std::string& moreText)
|
||||
{
|
||||
return MSG_BOX_OK;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue