forked from len0rd/rockbox
Save System Trace on exit and allow easy retrieval after restart.
The System Trace isn't preserved when quitting Rockbox Utility. Change this so the last trace is saved in the cache folder, and add a button to the trace window to allow easy saving it. Should help in cases where users have problems but restart Rockbox Utility before saving the trace. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25313 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
492fafe879
commit
56199d3dfb
4 changed files with 86 additions and 41 deletions
|
|
@ -149,6 +149,7 @@ void RbUtilQt::shutdown(void)
|
|||
// object destruction -- the trace object could already be destroyed.
|
||||
// Fixes segfaults on exit.
|
||||
qInstallMsgHandler(0);
|
||||
SysTrace::save();
|
||||
this->close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "systrace.h"
|
||||
#include "ui_systracefrm.h"
|
||||
|
||||
#include "rbsettings.h"
|
||||
|
||||
QString SysTrace::debugbuffer;
|
||||
|
||||
|
|
@ -32,7 +33,8 @@ SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
|
|||
refresh();
|
||||
|
||||
connect(ui.buttonClose, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(save()));
|
||||
connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(saveCurrentTrace()));
|
||||
connect(ui.buttonSavePrevious, SIGNAL(clicked()), this, SLOT(savePreviousTrace()));
|
||||
connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
|
||||
}
|
||||
|
||||
|
|
@ -41,22 +43,51 @@ void SysTrace::refresh(void)
|
|||
int pos = ui.textTrace->verticalScrollBar()->value();
|
||||
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
|
||||
ui.textTrace->verticalScrollBar()->setValue(pos);
|
||||
QString oldlog = RbSettings::value(RbSettings::CachePath).toString()
|
||||
+ "/rbutil-trace.log";
|
||||
ui.buttonSavePrevious->setEnabled(QFileInfo(oldlog).isFile());
|
||||
}
|
||||
|
||||
void SysTrace::save(void)
|
||||
{
|
||||
QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
|
||||
QDir::homePath(), "*.log");
|
||||
if(fp == "")
|
||||
return;
|
||||
|
||||
QFile fh(fp);
|
||||
void SysTrace::save(QString filename)
|
||||
{
|
||||
if(filename.isEmpty())
|
||||
filename = RbSettings::value(RbSettings::CachePath).toString()
|
||||
+ "/rbutil-trace.log";
|
||||
// append save date to the trace. Append it directly instead of using
|
||||
// qDebug() as the handler might have been unregistered.
|
||||
debugbuffer.append("[SysTrace] saving trace at ");
|
||||
debugbuffer.append(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
debugbuffer.append("\n");
|
||||
QFile fh(filename);
|
||||
if(!fh.open(QIODevice::WriteOnly))
|
||||
return;
|
||||
fh.write(debugbuffer.toUtf8(), debugbuffer.size());
|
||||
fh.close();
|
||||
}
|
||||
|
||||
void SysTrace::saveCurrentTrace(void)
|
||||
{
|
||||
QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
|
||||
QDir::homePath(), "*.log");
|
||||
if(!fp.isEmpty())
|
||||
save(fp);
|
||||
}
|
||||
|
||||
|
||||
void SysTrace::savePreviousTrace(void)
|
||||
{
|
||||
QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
|
||||
QDir::homePath(), "*.log");
|
||||
if(fp.isEmpty())
|
||||
return;
|
||||
|
||||
QString oldlog = RbSettings::value(RbSettings::CachePath).toString()
|
||||
+ "/rbutil-trace.log";
|
||||
QFile::copy(oldlog, fp);
|
||||
return;
|
||||
}
|
||||
|
||||
void SysTrace::debug(QtMsgType type, const char* msg)
|
||||
{
|
||||
(void)type;
|
||||
|
|
|
|||
|
|
@ -31,14 +31,15 @@ class SysTrace : public QDialog
|
|||
public:
|
||||
SysTrace(QWidget *parent);
|
||||
static void debug(QtMsgType type, const char* msg);
|
||||
|
||||
static QString getTrace() {return debugbuffer;}
|
||||
static void save(QString filename = "");
|
||||
private:
|
||||
Ui::SysTraceFrm ui;
|
||||
static QString debugbuffer;
|
||||
|
||||
private slots:
|
||||
void save(void);
|
||||
void saveCurrentTrace(void);
|
||||
void savePreviousTrace(void);
|
||||
void refresh(void);
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SysTraceFrm</class>
|
||||
<widget class="QDialog" name="SysTraceFrm">
|
||||
|
|
@ -13,7 +14,7 @@
|
|||
<string>System Trace</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="5" >
|
||||
<item row="0" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>System State trace</string>
|
||||
|
|
@ -23,7 +24,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="5" >
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="QTextEdit" name="textTrace"/>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="4" >
|
||||
<item row="2" column="5">
|
||||
<widget class="QPushButton" name="buttonClose">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
|
|
@ -50,7 +51,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="buttonSave">
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
|
|
@ -72,6 +73,17 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="buttonSavePrevious">
|
||||
<property name="text">
|
||||
<string>Save &previous</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="rbutilqt.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue