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 <simgear/simgear_config.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "MessageBox.hxx"
|
#include "MessageBox.hxx"
|
||||||
|
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
@ -146,16 +148,16 @@ MessageBoxResult modalMessageBox(const std::string& caption,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBoxResult fatalMessageBox(const std::string& caption,
|
[[noreturn]] void fatalMessageBox(const std::string& caption,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
const std::string& moreText)
|
const std::string& moreText)
|
||||||
{
|
{
|
||||||
#if defined(SG_WINDOWS)
|
#if defined(SG_WINDOWS)
|
||||||
return win32MessageBox(caption, msg, moreText);
|
win32MessageBox(caption, msg, moreText);
|
||||||
#elif defined(SG_MAC)
|
#elif defined(SG_MAC)
|
||||||
return cocoaFatalMessage(msg, moreText);
|
cocoaFatalMessage(msg, moreText);
|
||||||
#elif defined(HAVE_QT)
|
#elif defined(HAVE_QT)
|
||||||
return QtMessageBox(caption, msg, moreText, true);
|
QtMessageBox(caption, msg, moreText, true);
|
||||||
#else
|
#else
|
||||||
std::string s = "FATAL: "+ msg;
|
std::string s = "FATAL: "+ msg;
|
||||||
if (!moreText.empty()) {
|
if (!moreText.empty()) {
|
||||||
|
@ -169,8 +171,9 @@ MessageBoxResult fatalMessageBox(const std::string& caption,
|
||||||
dlg->setStringValue("text/label", s );
|
dlg->setStringValue("text/label", s );
|
||||||
_gui->showDialog("popup");
|
_gui->showDialog("popup");
|
||||||
}
|
}
|
||||||
return MSG_BOX_OK;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // of namespace flightgear
|
} // of namespace flightgear
|
||||||
|
|
|
@ -17,7 +17,7 @@ MessageBoxResult modalMessageBox(const std::string& caption,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
const std::string& moreText = std::string());
|
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& msg,
|
||||||
const std::string& moreText = std::string());
|
const std::string& moreText = std::string());
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
@ -112,11 +113,11 @@ namespace flightgear
|
||||||
return MSG_BOX_OK;
|
return MSG_BOX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBoxResult fatalMessageBox(const std::string& caption,
|
[[noreturn]] void fatalMessageBox(const std::string& caption,
|
||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
const std::string& moreText)
|
const std::string& moreText)
|
||||||
{
|
{
|
||||||
return MSG_BOX_OK;
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue