X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fmain.cpp;h=a1e39bad6833d61b74e83b43d745e3d612fb4655;hp=7668fb4d6d3bb82dc280b79fa947c1f5b5de690b;hb=509042502f58be20e84ccc3ba1f4487e20d4d3a6;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/radiant/main.cpp b/radiant/main.cpp index 7668fb4d..a1e39bad 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -232,6 +232,41 @@ public: } }; +class LineLimitedTextOutputStream : public TextOutputStream +{ + TextOutputStream& outputStream; + std::size_t count; +public: + LineLimitedTextOutputStream(TextOutputStream& outputStream, std::size_t count) + : outputStream(outputStream), count(count) + { + } + std::size_t write(const char* buffer, std::size_t length) + { + if(count != 0) + { + const char* p = buffer; + const char* end = buffer+length; + for(;;) + { + p = std::find(p, end, '\n'); + if(p == end) + { + break; + } + ++p; + if(--count == 0) + { + length = p - buffer; + break; + } + } + outputStream.write(buffer, length); + } + return length; + } +}; + class PopupDebugMessageHandler : public DebugMessageHandler { StringOutputStream m_buffer; @@ -248,26 +283,25 @@ public: bool handleMessage() { getOutputStream() << "----------------\n"; - write_stack_trace(getOutputStream()); + LineLimitedTextOutputStream outputStream(getOutputStream(), 24); + write_stack_trace(outputStream); getOutputStream() << "----------------\n"; + globalErrorStream() << m_buffer.c_str(); if(!m_lock.locked()) { ScopedLock lock(m_lock); #if defined _DEBUG m_buffer << "Break into the debugger?\n"; - globalErrorStream() << m_buffer.c_str(); bool handled = gtk_MessageBox(0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_YESNO, eMB_ICONERROR) == eIDNO; m_buffer.clear(); return handled; #else m_buffer << "Please report this error to the developers\n"; - globalErrorStream() << m_buffer.c_str(); gtk_MessageBox(0, m_buffer.c_str(), "Radiant - Runtime Error", eMB_OK, eMB_ICONERROR); m_buffer.clear(); - return true; #endif } - return false; + return true; } }; @@ -550,9 +584,9 @@ int main (int argc, char* argv[]) remove_global_pid(); - create_local_pid(); + g_Preferences.Init(); // must occur before create_local_pid() to allow preferences to be reset - g_Preferences.Init(); + create_local_pid(); // in a very particular post-.pid startup // we may have the console turned on and want to keep it that way @@ -619,3 +653,4 @@ int main (int argc, char* argv[]) return EXIT_SUCCESS; } +