Skip to content

Commit

Permalink
guard against recursive error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Oct 16, 2019
1 parent b2e6d0f commit 0a525b2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/cpp/core/include/core/Macros.hpp
Expand Up @@ -19,6 +19,14 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>


#define RS_CALL_ONCE() \
do \
{ \
static bool s_once = false; \
if (s_once) return; \
s_once = true; \
} while (0)

/* Work around Xcode indentation rules */ /* Work around Xcode indentation rules */
#define RS_BEGIN_NAMESPACE(__X__) namespace __X__ { #define RS_BEGIN_NAMESPACE(__X__) namespace __X__ {
#define RS_END_NAMESPACE(__X__) } #define RS_END_NAMESPACE(__X__) }
Expand Down
5 changes: 4 additions & 1 deletion src/cpp/desktop/DesktopMainWindow.cpp
Expand Up @@ -21,6 +21,7 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>


#include <core/Macros.hpp>
#include <core/text/TemplateFilter.hpp> #include <core/text/TemplateFilter.hpp>


#include "DesktopOptions.hpp" #include "DesktopOptions.hpp"
Expand Down Expand Up @@ -522,13 +523,15 @@ void MainWindow::onLoadFinished(bool ok)
if (ok) if (ok)
return; return;


RS_CALL_ONCE();

std::map<std::string,std::string> vars; std::map<std::string,std::string> vars;
vars["url"] = webView()->url().url().toStdString(); vars["url"] = webView()->url().url().toStdString();
std::ostringstream oss; std::ostringstream oss;
Error error = text::renderTemplate(options().resourcesPath().complete("html/connect.html"), Error error = text::renderTemplate(options().resourcesPath().complete("html/connect.html"),
vars, oss); vars, oss);
if (error) if (error)
LOG_ERROR(error); LOG_ERROR(error);
else else
loadHtml(QString::fromStdString(oss.str())); loadHtml(QString::fromStdString(oss.str()));
} }
Expand Down
3 changes: 3 additions & 0 deletions src/cpp/desktop/DesktopSessionLauncher.cpp
Expand Up @@ -19,6 +19,7 @@


#include <boost/bind.hpp> #include <boost/bind.hpp>


#include <core/Macros.hpp>
#include <core/http/Request.hpp> #include <core/http/Request.hpp>
#include <core/http/Response.hpp> #include <core/http/Response.hpp>
#include <core/http/TcpIpBlockingClient.hpp> #include <core/http/TcpIpBlockingClient.hpp>
Expand Down Expand Up @@ -267,6 +268,8 @@ Error getRecentSessionLogs(std::string* pLogFile, std::string *pLogContents)


void SessionLauncher::showLaunchErrorPage() void SessionLauncher::showLaunchErrorPage()
{ {
RS_CALL_ONCE();

// String mapping of template codes to diagnostic information // String mapping of template codes to diagnostic information
std::map<std::string,std::string> vars; std::map<std::string,std::string> vars;


Expand Down

0 comments on commit 0a525b2

Please sign in to comment.