mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 17:42:36 -05:00
Create Qt5 compatible version of trace event handler.
Qt5 deprecates the way this was done before. Change-Id: Ic66bce2d1ffcb572a9ed9345abbbbc6bb6475af0
This commit is contained in:
parent
d06779d987
commit
2dab7c9775
4 changed files with 32 additions and 0 deletions
|
|
@ -30,7 +30,11 @@ Q_IMPORT_PLUGIN(qtaccessiblewidgets)
|
|||
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
#if QT_VERSION < 0x050000
|
||||
qInstallMsgHandler(SysTrace::debug);
|
||||
#else
|
||||
qInstallMessageHandler(SysTrace::debug);
|
||||
#endif
|
||||
QApplication app( argc, argv );
|
||||
#if defined(Q_OS_MAC)
|
||||
QDir dir(QApplication::applicationDirPath());
|
||||
|
|
|
|||
|
|
@ -183,7 +183,11 @@ void RbUtilQt::shutdown(void)
|
|||
// restore default message handler to prevent trace accesses during
|
||||
// object destruction -- the trace object could already be destroyed.
|
||||
// Fixes segfaults on exit.
|
||||
#if QT_VERSION < 0x050000
|
||||
qInstallMsgHandler(0);
|
||||
#else
|
||||
qInstallMessageHandler(0);
|
||||
#endif
|
||||
SysTrace::save();
|
||||
this->close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ void SysTrace::savePreviousTrace(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
void SysTrace::debug(QtMsgType type, const char* msg)
|
||||
{
|
||||
(void)type;
|
||||
|
|
@ -109,6 +110,25 @@ void SysTrace::debug(QtMsgType type, const char* msg)
|
|||
repeat++;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void SysTrace::debug(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
(void)type;
|
||||
QByteArray localMsg = msg.toLocal8Bit();
|
||||
if(lastmessage != msg) {
|
||||
lastmessage = msg;
|
||||
flush();
|
||||
debugbuffer.append(msg + "\n");
|
||||
#if !defined(NODEBUG)
|
||||
fprintf(stderr, "%s\n", localMsg.constData());
|
||||
#endif
|
||||
repeat = 1;
|
||||
}
|
||||
else {
|
||||
repeat++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void SysTrace::flush(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ class SysTrace : public QDialog
|
|||
Q_OBJECT
|
||||
public:
|
||||
SysTrace(QWidget *parent);
|
||||
#if QT_VERSION < 0x050000
|
||||
static void debug(QtMsgType type, const char* msg);
|
||||
#else
|
||||
static void debug(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
#endif
|
||||
static QString getTrace() {return debugbuffer;}
|
||||
static void save(QString filename = "");
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue