summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 08:31:47 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-01 08:31:47 +0000
commitac153cc272c65fcb93085355e9f7defcac462fdb (patch)
treeb67a6c9af034e41ea4b4e80c1c77265938ffe6c0 /base
parentf8f606ef03a8afd7564c7f5a1bf82b54e6a6b392 (diff)
downloadchromium_src-ac153cc272c65fcb93085355e9f7defcac462fdb.zip
chromium_src-ac153cc272c65fcb93085355e9f7defcac462fdb.tar.gz
chromium_src-ac153cc272c65fcb93085355e9f7defcac462fdb.tar.bz2
linux: use xmessage for the dialog used in LOG(FATAL)
The previous code printed to stderr, but since the logging code already had logged to stderr we'd end up printing the message twice, which was making me nervous. BUG=31243,37026 Review URL: http://codereview.chromium.org/661260 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/logging.cc37
1 files changed, 24 insertions, 13 deletions
diff --git a/base/logging.cc b/base/logging.cc
index 72630fc..1212fd2 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -47,6 +47,7 @@ typedef pthread_mutex_t* MutexHandle;
#if defined(OS_POSIX)
#include "base/safe_strerror_posix.h"
#endif
+#include "base/process_util.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -328,19 +329,19 @@ void SetLogMessageHandler(LogMessageHandlerFunction handler) {
}
-// Displays a message box to the user with the error message in it. For
-// Windows programs, it's possible that the message loop is messed up on
-// a fatal error, and creating a MessageBox will cause that message loop
-// to be run. Instead, we try to spawn another process that displays its
-// command line. We look for "Debug Message.exe" in the same directory as
-// the application. If it exists, we use it, otherwise, we use a regular
-// message box.
-void DisplayDebugMessage(const std::string& str) {
+// Displays a message box to the user with the error message in it.
+// Used for fatal messages, where we close the app simultaneously.
+void DisplayDebugMessageInDialog(const std::string& str) {
if (str.empty())
return;
#if defined(OS_WIN)
- // look for the debug dialog program next to our application
+ // For Windows programs, it's possible that the message loop is
+ // messed up on a fatal error, and creating a MessageBox will cause
+ // that message loop to be run. Instead, we try to spawn another
+ // process that displays its command line. We look for "Debug
+ // Message.exe" in the same directory as the application. If it
+ // exists, we use it, otherwise, we use a regular message box.
wchar_t prog_name[MAX_PATH];
GetModuleFileNameW(NULL, prog_name, MAX_PATH);
wchar_t* backslash = wcsrchr(prog_name, '\\');
@@ -367,9 +368,19 @@ void DisplayDebugMessage(const std::string& str) {
MessageBoxW(NULL, &cmdline[0], L"Fatal error",
MB_OK | MB_ICONHAND | MB_TOPMOST);
}
+#elif defined(USE_X11)
+ // Shell out to xmessage, which behaves like debug_message.exe, but is
+ // way more retro. We could use zenity/kdialog but then we're starting
+ // to get into needing to check the desktop env and this dialog should
+ // only be coming up in Very Bad situations.
+ std::vector<std::string> argv;
+ argv.push_back("xmessage");
+ argv.push_back(str);
+ base::LaunchApp(argv, base::file_handle_mapping_vector(), true /* wait */,
+ NULL);
#else
- fprintf(stderr, "%s\n", str.c_str());
- fflush(stderr);
+ // http://code.google.com/p/chromium/issues/detail?id=37026
+ NOTIMPLEMENTED();
#endif
}
@@ -581,7 +592,7 @@ LogMessage::~LogMessage() {
// information, and displaying message boxes when the application is
// hosed can cause additional problems.
#ifndef NDEBUG
- DisplayDebugMessage(stream_.str());
+ DisplayDebugMessageInDialog(stream_.str());
#endif
// Crash the process to generate a dump.
DebugUtil::BreakDebugger();
@@ -592,7 +603,7 @@ LogMessage::~LogMessage() {
if (log_report_handler) {
log_report_handler(std::string(stream_.str()));
} else {
- DisplayDebugMessage(stream_.str());
+ DisplayDebugMessageInDialog(stream_.str());
}
}
}