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.
|
// object destruction -- the trace object could already be destroyed.
|
||||||
// Fixes segfaults on exit.
|
// Fixes segfaults on exit.
|
||||||
qInstallMsgHandler(0);
|
qInstallMsgHandler(0);
|
||||||
|
SysTrace::save();
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "systrace.h"
|
#include "systrace.h"
|
||||||
#include "ui_systracefrm.h"
|
#include "ui_systracefrm.h"
|
||||||
|
|
||||||
|
#include "rbsettings.h"
|
||||||
|
|
||||||
QString SysTrace::debugbuffer;
|
QString SysTrace::debugbuffer;
|
||||||
|
|
||||||
|
|
@ -32,7 +33,8 @@ SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
connect(ui.buttonClose, SIGNAL(clicked()), this, SLOT(close()));
|
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()));
|
connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,22 +43,51 @@ void SysTrace::refresh(void)
|
||||||
int pos = ui.textTrace->verticalScrollBar()->value();
|
int pos = ui.textTrace->verticalScrollBar()->value();
|
||||||
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
|
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
|
||||||
ui.textTrace->verticalScrollBar()->setValue(pos);
|
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"),
|
if(filename.isEmpty())
|
||||||
QDir::homePath(), "*.log");
|
filename = RbSettings::value(RbSettings::CachePath).toString()
|
||||||
if(fp == "")
|
+ "/rbutil-trace.log";
|
||||||
return;
|
// append save date to the trace. Append it directly instead of using
|
||||||
|
// qDebug() as the handler might have been unregistered.
|
||||||
QFile fh(fp);
|
debugbuffer.append("[SysTrace] saving trace at ");
|
||||||
|
debugbuffer.append(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||||
|
debugbuffer.append("\n");
|
||||||
|
QFile fh(filename);
|
||||||
if(!fh.open(QIODevice::WriteOnly))
|
if(!fh.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
fh.write(debugbuffer.toUtf8(), debugbuffer.size());
|
fh.write(debugbuffer.toUtf8(), debugbuffer.size());
|
||||||
fh.close();
|
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 SysTrace::debug(QtMsgType type, const char* msg)
|
||||||
{
|
{
|
||||||
(void)type;
|
(void)type;
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,15 @@ class SysTrace : public QDialog
|
||||||
public:
|
public:
|
||||||
SysTrace(QWidget *parent);
|
SysTrace(QWidget *parent);
|
||||||
static void debug(QtMsgType type, const char* msg);
|
static void debug(QtMsgType type, const char* msg);
|
||||||
|
|
||||||
static QString getTrace() {return debugbuffer;}
|
static QString getTrace() {return debugbuffer;}
|
||||||
|
static void save(QString filename = "");
|
||||||
private:
|
private:
|
||||||
Ui::SysTraceFrm ui;
|
Ui::SysTraceFrm ui;
|
||||||
static QString debugbuffer;
|
static QString debugbuffer;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void save(void);
|
void saveCurrentTrace(void);
|
||||||
|
void savePreviousTrace(void);
|
||||||
void refresh(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>
|
<class>SysTraceFrm</class>
|
||||||
<widget class="QDialog" name="SysTraceFrm" >
|
<widget class="QDialog" name="SysTraceFrm">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
|
|
@ -9,29 +10,29 @@
|
||||||
<height>550</height>
|
<height>550</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>System Trace</string>
|
<string>System Trace</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" >
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="5" >
|
<item row="0" column="0" colspan="6">
|
||||||
<widget class="QLabel" name="label" >
|
<widget class="QLabel" name="label">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>System State trace</string>
|
<string>System State trace</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap" >
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="5" >
|
<item row="1" column="0" colspan="6">
|
||||||
<widget class="QTextEdit" name="textTrace" />
|
<widget class="QTextEdit" name="textTrace"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2" >
|
<item row="2" column="1" colspan="2">
|
||||||
<spacer name="horizontalSpacer" >
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation" >
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0" >
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>487</width>
|
<width>487</width>
|
||||||
<height>26</height>
|
<height>26</height>
|
||||||
|
|
@ -39,43 +40,54 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4" >
|
<item row="2" column="5">
|
||||||
<widget class="QPushButton" name="buttonClose" >
|
<widget class="QPushButton" name="buttonClose">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Close</string>
|
<string>&Close</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon" >
|
<property name="icon">
|
||||||
<iconset resource="rbutilqt.qrc" >
|
<iconset resource="rbutilqt.qrc">
|
||||||
<normaloff>:/icons/process-stop.png</normaloff>:/icons/process-stop.png</iconset>
|
<normaloff>:/icons/process-stop.png</normaloff>:/icons/process-stop.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="3" >
|
<item row="2" column="4">
|
||||||
<widget class="QPushButton" name="buttonSave" >
|
<widget class="QPushButton" name="buttonSave">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Save</string>
|
<string>&Save</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon" >
|
<property name="icon">
|
||||||
<iconset resource="rbutilqt.qrc" >
|
<iconset resource="rbutilqt.qrc">
|
||||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" >
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="buttonRefresh" >
|
<widget class="QPushButton" name="buttonRefresh">
|
||||||
<property name="text" >
|
<property name="text">
|
||||||
<string>&Refresh</string>
|
<string>&Refresh</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon" >
|
<property name="icon">
|
||||||
<iconset resource="rbutilqt.qrc" >
|
<iconset resource="rbutilqt.qrc">
|
||||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="rbutilqt.qrc" />
|
<include location="rbutilqt.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue