Index: ps/trunk/source/gui/GUIManager.h =================================================================== --- ps/trunk/source/gui/GUIManager.h +++ ps/trunk/source/gui/GUIManager.h @@ -59,9 +59,9 @@ shared_ptr GetActiveGUI() { return top(); } /** - * Returns whether there are any current pages. + * Returns the number of currently open GUI pages. */ - bool HasPages(); + size_t GetPageCount() const; /** * Load a new GUI page and make it active. All current pages will be destroyed. Index: ps/trunk/source/gui/GUIManager.cpp =================================================================== --- ps/trunk/source/gui/GUIManager.cpp +++ ps/trunk/source/gui/GUIManager.cpp @@ -73,9 +73,9 @@ UnregisterFileReloadFunc(ReloadChangedFileCB, this); } -bool CGUIManager::HasPages() +size_t CGUIManager::GetPageCount() const { - return !m_PageStack.empty(); + return m_PageStack.size(); } void CGUIManager::SwitchPage(const CStrW& pageName, ScriptInterface* srcScriptInterface, JS::HandleValue initData) Index: ps/trunk/source/gui/scripting/JSInterface_GUIManager.cpp =================================================================== --- ps/trunk/source/gui/scripting/JSInterface_GUIManager.cpp +++ ps/trunk/source/gui/scripting/JSInterface_GUIManager.cpp @@ -39,6 +39,14 @@ void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args) { + if (g_GUI->GetPageCount() < 2) + { + JSContext* cx = pCxPrivate->pScriptInterface->GetContext(); + JSAutoRequest rq(cx); + JS_ReportError(cx, "Can't pop GUI pages when less than two pages are opened!"); + return; + } + g_GUI->PopPage(pCxPrivate->pScriptInterface->WriteStructuredClone(args)); } Index: ps/trunk/source/ps/Game.cpp =================================================================== --- ps/trunk/source/ps/Game.cpp +++ ps/trunk/source/ps/Game.cpp @@ -320,7 +320,7 @@ g_NetClient->LoadFinished(); // Call the reallyStartGame GUI function, but only if it exists - if (g_GUI && g_GUI->HasPages()) + if (g_GUI && g_GUI->GetPageCount()) { JS::RootedValue global(cx, g_GUI->GetActiveGUI()->GetGlobalObject()); if (g_GUI->GetActiveGUI()->GetScriptInterface()->HasProperty(global, "reallyStartGame")) Index: ps/trunk/source/ps/GameSetup/GameSetup.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/GameSetup.cpp +++ ps/trunk/source/ps/GameSetup/GameSetup.cpp @@ -1667,7 +1667,7 @@ LDR_Cancel(); if (g_GUI && - g_GUI->HasPages() && + g_GUI->GetPageCount() && pScriptInterface->HasProperty(global, "cancelOnLoadGameError")) pScriptInterface->CallFunctionVoid(global, "cancelOnLoadGameError", message); }