limited win32 stack-trace size
authorspog <spog>
Sun, 9 Apr 2006 18:16:41 +0000 (18:16 +0000)
committerspog <spog>
Sun, 9 Apr 2006 18:16:41 +0000 (18:16 +0000)
git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@46 8a3a26a2-13c4-0310-b231-cf6edde360e5

19 files changed:
contrib/prtview/prtview.cpp
include/modulesystem.h
plugins/archivepak/plugin.cpp
plugins/archivewad/plugin.cpp
plugins/archivezip/plugin.cpp
plugins/entity/plugin.cpp
plugins/image/image.cpp
plugins/imagehl/imagehl.cpp
plugins/imagepng/plugin.cpp
plugins/imageq2/imageq2.cpp
plugins/mapq3/plugin.cpp
plugins/mapxml/plugin.cpp
plugins/md3model/plugin.cpp
plugins/model/plugin.cpp
plugins/sample/sample.cpp
plugins/shaders/plugin.cpp
plugins/vfspk3/vfspk3.cpp
radiant/console.cpp
radiant/main.cpp

index 2d4cebb0302166faa8e791fd421343c439afc433..34c6e70f3916a065e271b3dc9596fd28c3468eab 100644 (file)
@@ -320,10 +320,7 @@ SingletonPrtViewPluginModule g_PrtViewPluginModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_PrtViewPluginModule.selfRegister();
 }
index 7cb6d3f53d060f95a105cf5e4b8a0bae190494e4..4c5495d299d682dc170e8cc7c2a7950f42e8108b 100644 (file)
@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define INCLUDED_MODULESYSTEM_H
 
 #include "generic/static.h"
+#include "debugging/debugging.h"
 
 #if defined(WIN32)
 #define RADIANT_DLLEXPORT __stdcall
@@ -94,6 +95,16 @@ inline ModuleServer& globalModuleServer()
 }
 
 
+inline void initialiseModule(ModuleServer& server)
+{
+  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
+  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
+  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
+  GlobalModuleServer::instance().set(server);
+}
+
+
+
 template<typename Type>
 class Modules
 {
index c141523fb848652e156252093e2ce1dd0f64908e..d73b0ef5c02b1ac02285f5481fec38909e10f002 100644 (file)
@@ -52,10 +52,7 @@ ArchivePakModule g_ArchivePakModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ArchivePakModule.selfRegister();
 }
index cf5f69190d354a2c8a39083bae88d899321f1405..a27c459999f7bda1b36a5f14fbad73ec0d804ad5 100644 (file)
@@ -52,10 +52,7 @@ ArchiveWadModule g_ArchiveWadModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ArchiveWadModule.selfRegister();
 }
index 59e2511ebaeb9720c0fa6125b8bdf007af0b3727..82a5a2ab0758cb8406084c1b2c6e13ab26657522 100644 (file)
@@ -75,10 +75,7 @@ ArchivePK4Module g_ArchivePK4Module;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ArchiveZipModule.selfRegister();
   g_ArchivePK4Module.selfRegister();
index 947befb3fe9829107fd7728d4488b69019e78df5..58ace895bb2d9efc5167320c4ecbc10ecb8263f0 100644 (file)
@@ -151,10 +151,7 @@ EntityDoom3Module g_EntityDoom3Module;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_EntityQ3Module.selfRegister();
   g_EntityWolfModule.selfRegister();
index 2a4afb2369c9ca04c561209eb471ecdc9938c1bc..4436dde448be14fa03bb5b3b52d8448c26693de2 100644 (file)
@@ -149,10 +149,7 @@ ImageDDSModule g_ImageDDSModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ImageTGAModule.selfRegister();
   g_ImageJPGModule.selfRegister();
index 7cbe07a3d14f8a986d628c63c5f820da9ed5ffab..af05104432c593d315fa3ed003e89b92ef21aad3 100644 (file)
@@ -105,10 +105,7 @@ ImageSpriteModule g_ImageSpriteModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ImageHLWModule.selfRegister();
   g_ImageMipModule.selfRegister();
index 1247ba9babb2d7f6a716bc188b24bdb782840f45..426c4f063e3bbb013e3a155794f89de0bb5ae98b 100644 (file)
@@ -198,10 +198,7 @@ ImagePNGModule g_ImagePNGModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ImagePNGModule.selfRegister();
 }
index 338b5e21602f77def2c1743569a96aa48a3d19d7..dfd64467d42147c2c06f4b980558f1faf5ef54de 100644 (file)
@@ -106,10 +106,7 @@ ImageM32Module g_ImageM32Module;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ImageWalModule.selfRegister();
   g_ImageM8Module.selfRegister();
index 8e031edb1bcdf1525c69f59b07f9ebf45617d88e..a11dc4a9bf3633a25e10642aa6f4449f8f8cc3f6 100644 (file)
@@ -646,10 +646,7 @@ MapVMFModule g_MapVMFModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_MapDoom3Module.selfRegister();
   g_MapQuake4Module.selfRegister();
index 083cef8f4f5564fe647b026443e20d1451d4ad5a..6bb09be8bfef06b947400c6b8c42904b3fa006a8 100644 (file)
@@ -84,10 +84,7 @@ MapXMLModule g_MapXMLModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_MapXMLModule.selfRegister();
 }
index 42c2a92e4784a20efddd59ae81c83e2bf77901a2..dbdff93591137bd89bdaacb183bb61c243d63d8d 100644 (file)
@@ -236,10 +236,7 @@ ModelMD5Module g_ModelMD5Module;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ModelMD3Module.selfRegister();
   g_ModelMD2Module.selfRegister();
index 278388fd57278e2009bf45a634819e7c35b8970d..e032e3981a4378727317e0dad037f87077226c2b 100644 (file)
@@ -169,10 +169,7 @@ PicoModelModules g_PicoModelModules;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   pico_initialise();
 
index cec08dddee07e06a166196f888e1d06d5854e9ba..80900b10e9b7a25b014f1d1ad3f577b193a1fe48 100644 (file)
@@ -89,10 +89,7 @@ SingletonSamplePluginModule g_SamplePluginModule;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_SamplePluginModule.selfRegister();
 }
index 6732ca63ca998e9f763e15561126076f3488cd1b..6ef23c372b60d942f12559e0d37ac5057c2a92ce 100644 (file)
@@ -149,10 +149,7 @@ ShadersQuake4Module g_ShadersQuake4Module;
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_ShadersQ3Module.selfRegister();
   g_ShadersDoom3Module.selfRegister();
index ed250e3915cbd9ee0d9237d7429e865a2b7997db..e7fca37278878cefdc6d3b7bfa07718781f682b4 100644 (file)
@@ -79,10 +79,7 @@ ArchiveModules& FileSystemQ3API_getArchiveModules()
 
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
 {
-  GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
-  GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
-  GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
-  GlobalModuleServer::instance().set(server);
+  initialiseModule(server);
 
   g_FileSystemQ3Module.selfRegister();
 }
index f47c66da407c552833d5eadcd768e124e96d328e..f48a9877b77b44fa66189c8487d3defc7cfecb71 100644 (file)
@@ -155,7 +155,7 @@ public:
 
 std::size_t Sys_Print(int level, const char* buf, std::size_t length)
 {
-  bool contains_newline = strchr(buf, '\n') != 0;
+  bool contains_newline = std::find(buf, buf+length, '\n') != buf+length;
 
   if(level == SYS_ERR)
   {
index dc764663b4a0307d0129a2ca7619701e1fad6ce3..b66728a5a3de951bdf392cb590ab20bbd4705326 100644 (file)
@@ -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,7 +283,8 @@ public:
   bool handleMessage()
   {
     getOutputStream() << "----------------\n";
-    write_stack_trace(getOutputStream());
+    LineLimitedTextOutputStream outputStream(getOutputStream(), 24);
+    write_stack_trace(outputStream);
     getOutputStream() << "----------------\n";
     if(!m_lock.locked())
     {