diff options
Diffstat (limited to 'drkonqi')
-rw-r--r-- | drkonqi/backtrace.cpp | 35 | ||||
-rw-r--r-- | drkonqi/backtrace.h | 1 |
2 files changed, 28 insertions, 8 deletions
diff --git a/drkonqi/backtrace.cpp b/drkonqi/backtrace.cpp index e82ed614e..36a0fc8ff 100644 --- a/drkonqi/backtrace.cpp +++ b/drkonqi/backtrace.cpp @@ -42,7 +42,7 @@ BackTrace::BackTrace(const KrashConfig *krashconf, TQObject *parent, const char *name) : TQObject(parent, name), - m_krashconf(krashconf), m_temp(0) + m_krashconf(krashconf), m_temp(NULL), m_temp_cmd(NULL) { m_proc = new KProcess; } @@ -64,6 +64,7 @@ BackTrace::~BackTrace() } delete m_temp; + delete m_temp_cmd; } void BackTrace::start() @@ -92,14 +93,25 @@ void BackTrace::start() ::write(handle, "\n", 1); ::fsync(handle); + // build the debugger command + TQString str = m_krashconf->debuggerBatch(); + m_krashconf->expandString(str, true, m_temp->name()); + + // write the debugger command + m_temp_cmd = new KTempFile(TQString::null, TQString::null, 0700); + m_temp_cmd->setAutoDelete(TRUE); + handle = m_temp_cmd->handle(); + const char* dbgcommand = str.latin1(); + ::write(handle, dbgcommand, strlen(dbgcommand)); // the command to execute the debugger + ::write(handle, "\n", 1); + ::fsync(handle); + m_temp_cmd->close(); + // start the debugger m_proc = new KProcess; m_proc->setUseShell(true); - TQString str = m_krashconf->debuggerBatch(); - m_krashconf->expandString(str, true, m_temp->name()); - - *m_proc << str; + *m_proc << "kdesu -t --comment \"" << i18n("Administrative access is required to generate a backtrace") << "\" -c \"" << m_temp_cmd->name() << "\""; connect(m_proc, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), TQT_SLOT(slotReadInput(KProcess*, char*, int))); @@ -112,9 +124,16 @@ void BackTrace::start() void BackTrace::slotReadInput(KProcess *, char* buf, int buflen) { TQString newstr = TQString::fromLocal8Bit(buf, buflen); - m_strBt.append(newstr); - - emit append(newstr); + newstr.replace("\n\n", "\n"); + if (m_strBt.isEmpty()) { + if (newstr == "\n") { + newstr = ""; + } + } + if (!newstr.startsWith(": ")) { + m_strBt.append(newstr); + emit append(newstr); + } } void BackTrace::slotProcessExited(KProcess *proc) diff --git a/drkonqi/backtrace.h b/drkonqi/backtrace.h index 4a94bcfc6..661dc246d 100644 --- a/drkonqi/backtrace.h +++ b/drkonqi/backtrace.h @@ -61,6 +61,7 @@ private: KProcess *m_proc; const KrashConfig *m_krashconf; KTempFile *m_temp; + KTempFile *m_temp_cmd; TQString m_strBt; }; #endif |