diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-03-23 22:07:17 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2010-03-23 22:07:17 +0000 |
commit | 56199d3dfba2c2454c1226fac5d98e84ecf11cd1 (patch) | |
tree | 8a8e2dd58e9bb13279aa4b3427cca46261c5fe1f /rbutil | |
parent | 492fafe8792bf21f034d34bbef0e3d38383fa989 (diff) |
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
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/systrace.cpp | 47 | ||||
-rw-r--r-- | rbutil/rbutilqt/systrace.h | 5 | ||||
-rw-r--r-- | rbutil/rbutilqt/systracefrm.ui | 74 |
4 files changed, 86 insertions, 41 deletions
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 292a0026b1..ececb782d4 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -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(); } diff --git a/rbutil/rbutilqt/systrace.cpp b/rbutil/rbutilqt/systrace.cpp index 1aed5c05b5..1b9de6b713 100644 --- a/rbutil/rbutilqt/systrace.cpp +++ b/rbutil/rbutilqt/systrace.cpp @@ -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; diff --git a/rbutil/rbutilqt/systrace.h b/rbutil/rbutilqt/systrace.h index a8253ce9e6..4e6206a886 100644 --- a/rbutil/rbutilqt/systrace.h +++ b/rbutil/rbutilqt/systrace.h @@ -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); }; diff --git a/rbutil/rbutilqt/systracefrm.ui b/rbutil/rbutilqt/systracefrm.ui index 7a83eecb80..eb8bb6dac6 100644 --- a/rbutil/rbutilqt/systracefrm.ui +++ b/rbutil/rbutilqt/systracefrm.ui @@ -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> |