limited win32 stack-trace size

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@46 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-04-09 18:16:41 +00:00
parent cdb5b8a5c8
commit 95ac019c00
19 changed files with 65 additions and 66 deletions

View 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();
}

View 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
{

View 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();
}

View 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();
}

View 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();

View 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();

View 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();

View 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();

View 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();
}

View 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();

View 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();

View 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();
}

View 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();

View 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();

View 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();
}

View 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();

View 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();
}

View 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)
{

View 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())
{