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)
|
||||
|
||||
void SysTrace::save(QString filename)
|
||||
{
|
||||
QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
|
||||
QDir::homePath(), "*.log");
|
||||
if(fp == "")
|
||||
return;
|
||||
|
||||
QFile fh(fp);
|
||||
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,7 +1,8 @@
|
|||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SysTraceFrm</class>
|
||||
<widget class="QDialog" name="SysTraceFrm" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="SysTraceFrm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
|
@ -9,29 +10,29 @@
|
|||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>System Trace</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" colspan="5" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>System State trace</string>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="5" >
|
||||
<widget class="QTextEdit" name="textTrace" />
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="QTextEdit" name="textTrace"/>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<spacer name="horizontalSpacer" >
|
||||
<property name="orientation" >
|
||||
<item row="2" column="1" colspan="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>487</width>
|
||||
<height>26</height>
|
||||
|
@ -39,43 +40,54 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="4" >
|
||||
<widget class="QPushButton" name="buttonClose" >
|
||||
<property name="text" >
|
||||
<item row="2" column="5">
|
||||
<widget class="QPushButton" name="buttonClose">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="rbutilqt.qrc">
|
||||
<normaloff>:/icons/process-stop.png</normaloff>:/icons/process-stop.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" >
|
||||
<widget class="QPushButton" name="buttonSave" >
|
||||
<property name="text" >
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="buttonSave">
|
||||
<property name="text">
|
||||
<string>&Save</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="rbutilqt.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QPushButton" name="buttonRefresh" >
|
||||
<property name="text" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="buttonRefresh">
|
||||
<property name="text">
|
||||
<string>&Refresh</string>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="rbutilqt.qrc" >
|
||||
<property name="icon">
|
||||
<iconset resource="rbutilqt.qrc">
|
||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||
</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>
|
||||
<include location="rbutilqt.qrc" />
|
||||
<include location="rbutilqt.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in a new issue