1
0
Fork 0

Fix message-box crash in non-Qt builds.

Only affects Linux where we have no fallback UI option.

https://sourceforge.net/p/flightgear/codetickets/1900/
This commit is contained in:
James Turner 2016-10-20 19:52:21 +01:00
parent ce79be323a
commit ad43d52070

View file

@ -66,15 +66,15 @@ HWND getMainViewerHWND()
if (strcmp((*it)->className(), "GraphicsWindowWin32")) { if (strcmp((*it)->className(), "GraphicsWindowWin32")) {
continue; continue;
} }
osgViewer::GraphicsWindowWin32* platformWin = osgViewer::GraphicsWindowWin32* platformWin =
static_cast<osgViewer::GraphicsWindowWin32*>(*it); static_cast<osgViewer::GraphicsWindowWin32*>(*it);
return platformWin->getHWND(); return platformWin->getHWND();
} }
return 0; return 0;
} }
flightgear::MessageBoxResult flightgear::MessageBoxResult
win32MessageBox(const std::string& caption, win32MessageBox(const std::string& caption,
const std::string& msg, const std::string& msg,
@ -87,7 +87,7 @@ win32MessageBox(const std::string& caption,
if (!moreText.empty()) { if (!moreText.empty()) {
fullMsg += "\n\n" + moreText; fullMsg += "\n\n" + moreText;
} }
UINT mbType = MB_OK; UINT mbType = MB_OK;
std::wstring wMsg(convertUtf8ToWString(fullMsg)), std::wstring wMsg(convertUtf8ToWString(fullMsg)),
wCap(convertUtf8ToWString(caption)); wCap(convertUtf8ToWString(caption));
@ -97,14 +97,14 @@ win32MessageBox(const std::string& caption,
return flightgear::MSG_BOX_OK; return flightgear::MSG_BOX_OK;
} }
#endif #endif
} // anonymous namespace } // anonymous namespace
namespace flightgear namespace flightgear
{ {
MessageBoxResult modalMessageBox(const std::string& caption, MessageBoxResult modalMessageBox(const std::string& caption,
const std::string& msg, const std::string& msg,
const std::string& moreText) const std::string& moreText)
@ -116,9 +116,9 @@ MessageBoxResult modalMessageBox(const std::string& caption,
args->setStringValue("message", msg); args->setStringValue("message", msg);
args->setStringValue("more", moreText); args->setStringValue("more", moreText);
globals->get_commands()->execute("canvas-message-box", args); globals->get_commands()->execute("canvas-message-box", args);
// how to make it modal? // how to make it modal?
return MSG_BOX_OK; return MSG_BOX_OK;
} }
@ -134,13 +134,13 @@ MessageBoxResult modalMessageBox(const std::string& caption,
s += "\n( " + moreText + ")"; s += "\n( " + moreText + ")";
} }
if (fgGetBool("/sim/rendering/initialized", false) == false) { NewGUI* gui = globals->get_subsystem<NewGUI>();
if (!gui || (fgGetBool("/sim/rendering/initialized", false) == false)) {
SG_LOG(SG_GENERAL, SG_ALERT, s); SG_LOG(SG_GENERAL, SG_ALERT, s);
} else { } else {
NewGUI* _gui = (NewGUI *)globals->get_subsystem("gui"); SGPropertyNode_ptr dlg = gui->getDialogProperties("popup");
SGPropertyNode_ptr dlg = _gui->getDialogProperties("popup");
dlg->setStringValue("text/label", s ); dlg->setStringValue("text/label", s );
_gui->showDialog("popup"); gui->showDialog("popup");
} }
return MSG_BOX_OK; return MSG_BOX_OK;
#endif #endif