From b53b161dfae79f1bbb1dd2c8dff087b5e2365a26 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 19 Apr 2011 01:33:58 -0400 Subject: [PATCH] Large chunk of functionality to show errors. --- gui/apicalldelegate.cpp | 9 ++- gui/apicalldelegate.h | 1 + gui/apitrace.cpp | 5 ++ gui/apitrace.h | 1 + gui/apitracecall.cpp | 100 ++++++++++++++++++++++++++++----- gui/apitracecall.h | 8 +++ gui/apitracemodel.cpp | 9 +-- gui/mainwindow.cpp | 6 ++ gui/qapitrace.qrc | 1 + gui/resources/script-error.png | Bin 0 -> 1709 bytes gui/saverthread.cpp | 2 +- gui/ui/mainwindow.ui | 35 ++++++++++++ 12 files changed, 157 insertions(+), 20 deletions(-) create mode 100644 gui/resources/script-error.png diff --git a/gui/apicalldelegate.cpp b/gui/apicalldelegate.cpp index c2a1b23..800fcdd 100644 --- a/gui/apicalldelegate.cpp +++ b/gui/apicalldelegate.cpp @@ -12,7 +12,8 @@ ApiCallDelegate::ApiCallDelegate(QWidget *parent) : QStyledItemDelegate(parent), m_stateEmblem(":/resources/dialog-information.png"), - m_editEmblem(":/resources/document-edit.png") + m_editEmblem(":/resources/document-edit.png"), + m_errorEmblem(":/resources/script-error.png") { } @@ -40,6 +41,12 @@ void ApiCallDelegate::paint(QPainter *painter, } if (event->type() == ApiTraceEvent::Call) { ApiTraceCall *call = static_cast(event); + if (call->hasError()) { + QPixmap px = m_errorEmblem.pixmap(option.rect.height(), + option.rect.height()); + painter->drawPixmap(option.rect.topLeft() + offset, px); + offset += QPoint(option.rect.height() + 5, 0); + } if (call->edited()) { QPixmap px = m_editEmblem.pixmap(option.rect.height(), option.rect.height()); diff --git a/gui/apicalldelegate.h b/gui/apicalldelegate.h index 55cd13e..18c8b33 100644 --- a/gui/apicalldelegate.h +++ b/gui/apicalldelegate.h @@ -18,6 +18,7 @@ public: private: QIcon m_stateEmblem; QIcon m_editEmblem; + QIcon m_errorEmblem; }; #endif diff --git a/gui/apitrace.cpp b/gui/apitrace.cpp index 4ce4cd4..6fa994a 100644 --- a/gui/apitrace.cpp +++ b/gui/apitrace.cpp @@ -260,4 +260,9 @@ bool ApiTrace::isSaving() const return m_saver->isRunning(); } +void ApiTrace::callError(ApiTraceCall *call) +{ + emit changed(call); +} + #include "apitrace.moc" diff --git a/gui/apitrace.h b/gui/apitrace.h index 32e2408..a493fd2 100644 --- a/gui/apitrace.h +++ b/gui/apitrace.h @@ -45,6 +45,7 @@ public: void callEdited(ApiTraceCall *call); void callReverted(ApiTraceCall *call); + void callError(ApiTraceCall *call); bool edited() const; bool needsSaving() const; diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index b2ded2f..bac3d73 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -8,6 +8,38 @@ #define QT_USE_FAST_OPERATOR_PLUS #include +const char * const styleSheet = + ".call {\n" + " font-weight:bold;\n" + // text shadow looks great but doesn't work well in qtwebkit 4.7 + " /*text-shadow: 0px 2px 3px #555;*/\n" + " font-size: 1.2em;\n" + "}\n" + ".arg-name {\n" + " border: 1px solid rgb(238,206,0);\n" + " border-radius: 4px;\n" + " background: yellow;\n" + " padding: 2px;\n" + " box-shadow: 0px 1px 3px dimgrey;\n" + " -webkit-transition: background 1s linear;\n" + "}\n" + ".arg-name:hover {\n" + " background: white;\n" + "}\n" + ".arg-value {\n" + " color: #0000ff;\n" + "}\n" + ".error {\n" + " margin: 10px;\n" + " padding: 0;\n" + " color: red;\n" + " background: #6fb2e5;\n" + " box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n" + " -o-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n" + " -webkit-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n" + " -moz-box-shadow: 0 1px 5px #0061aa, inset 0 10px 20px #b6f9ff;\n" + "}\n"; + ApiPointer::ApiPointer(unsigned long long val) : m_value(val) { @@ -316,14 +348,16 @@ QString ApiTraceCall::toHtml() const if (!m_richText.isEmpty()) return m_richText; + m_richText = QLatin1String("
"); + if (m_helpUrl.isEmpty()) { - m_richText = QString::fromLatin1( - "%1) %2(") - .arg(m_index) - .arg(m_name); + m_richText += QString::fromLatin1( + "%1) %2(") + .arg(m_index) + .arg(m_name); } else { - m_richText = QString::fromLatin1( - "%1) %3(") + m_richText += QString::fromLatin1( + "%1) %3(") .arg(m_index) .arg(m_helpUrl.toString()) .arg(m_name); @@ -331,11 +365,14 @@ QString ApiTraceCall::toHtml() const QVariantList argValues = arguments(); for (int i = 0; i < m_argNames.count(); ++i) { - m_richText += m_argNames[i] + - QLatin1Literal(" = ") + - QLatin1Literal("") + - apiVariantToString(argValues[i]) + - QLatin1Literal(""); + m_richText += + QLatin1String("") + + m_argNames[i] + + QLatin1String("") + + QLatin1Literal(" = ") + + QLatin1Literal("") + + apiVariantToString(argValues[i]) + + QLatin1Literal(""); if (i < m_argNames.count() - 1) m_richText += QLatin1String(", "); } @@ -348,7 +385,17 @@ QString ApiTraceCall::toHtml() const apiVariantToString(m_returnValue) + QLatin1String(""); } + m_richText += QLatin1String("
"); + + m_richText = + QString::fromLatin1( + "%2") + .arg(styleSheet) + .arg(m_richText); m_richText.squeeze(); + + //qDebug()<parentTrace(); + ApiTrace *trace = parentTrace(); m_editedValues = lst; //lets regenerate data @@ -754,3 +799,30 @@ unsigned long long ApiPointer::value() const return m_value; } +bool ApiTraceCall::hasError() const +{ + return !m_error.isEmpty(); +} + +QString ApiTraceCall::error() const +{ + return m_error; +} + +void ApiTraceCall::setError(const QString &msg) +{ + if (m_error != msg) { + ApiTrace *trace = parentTrace(); + m_error = msg; + if (trace) + trace->callError(this); + } +} + +ApiTrace * ApiTraceCall::parentTrace() const +{ + if (m_parentFrame) + return m_parentFrame->parentTrace(); + return NULL; +} + diff --git a/gui/apitracecall.h b/gui/apitracecall.h index 59c6fe7..3afd2ab 100644 --- a/gui/apitracecall.h +++ b/gui/apitracecall.h @@ -195,6 +195,10 @@ public: ApiTraceFrame *parentFrame()const; void setParentFrame(ApiTraceFrame *frame); + bool hasError() const; + QString error() const; + void setError(const QString &msg); + QVariantList originalValues() const; bool edited() const; @@ -202,6 +206,8 @@ public: QVariantList editedValues() const; void revert(); + ApiTrace *parentTrace() const; + QString toHtml() const; QString filterText() const; QStaticText staticText() const; @@ -219,6 +225,8 @@ private: QVariantList m_editedValues; + QString m_error; + mutable QString m_richText; mutable QString m_filterText; mutable bool m_hasBinaryData; diff --git a/gui/apitracemodel.cpp b/gui/apitracemodel.cpp index a39a929..70d292a 100644 --- a/gui/apitracemodel.cpp +++ b/gui/apitracemodel.cpp @@ -282,16 +282,17 @@ void ApiTraceModel::callChanged(ApiTraceCall *call) { ApiTrace *trace = call->parentFrame()->parentTrace(); - Q_ASSERT(trace); - trace->save(); - -#if 0 +#if 1 qDebug()<<"Call changed = "<edited(); qDebug()<<"\ttrace edited = "<edited(); qDebug()<<"\ttrace file = "<fileName(); qDebug()<<"\ttrace needs saving = "<needsSaving(); #endif + Q_ASSERT(trace); + if (trace->needsSaving()) + trace->save(); + ApiTraceFrame *frame = call->parentFrame(); int row = frame->calls.indexOf(call); QModelIndex index = createIndex(row, 0, call); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index f40a144..1af5af0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -606,11 +606,13 @@ void MainWindow::initObjects() m_argsEditor = new ArgumentsEditor(this); m_ui.detailsDock->hide(); + m_ui.errorsDock->hide(); m_ui.vertexDataDock->hide(); m_ui.stateDock->hide(); setDockOptions(dockOptions() | QMainWindow::ForceTabbedDocks); tabifyDockWidget(m_ui.stateDock, m_ui.vertexDataDock); + tabifyDockWidget(m_ui.detailsDock, m_ui.errorsDock); m_ui.surfacesTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -725,6 +727,10 @@ void MainWindow::initConnections() void MainWindow::replayStateFound(const ApiTraceState &state) { m_stateEvent->setState(state); + if (m_stateEvent->type() == ApiTraceEvent::Call) { + ApiTraceCall *call = static_cast(m_stateEvent); + call->setError(tr("Some wonky error.")); + } m_model->stateSetOnEvent(m_stateEvent); if (m_selectedEvent == m_stateEvent) { fillStateForFrame(); diff --git a/gui/qapitrace.qrc b/gui/qapitrace.qrc index 4d8223f..fe002f1 100644 --- a/gui/qapitrace.qrc +++ b/gui/qapitrace.qrc @@ -17,6 +17,7 @@ resources/media-playback-start.png resources/media-playback-stop.png resources/media-record.png + resources/script-error.png resources/glreference.tsv diff --git a/gui/resources/script-error.png b/gui/resources/script-error.png new file mode 100644 index 0000000000000000000000000000000000000000..c7ace707e3a21503efe02b1b32cd913926c7dc92 GIT binary patch literal 1709 zcmV;e22%NnP)4Q?BA8iq7DN{gO5vCY)0y>mQ z)D02iOs2%mq0@yaS+dQM83P$QBb#m-W`fz&jYNUCI3FzX z=*#-C(Jf$XtC=xRY;5cX^rhh>ATbyW>r^V0KZ~)EWeP>PiLp|f&6cdw>0Bv{&7IEJ z!VHzlhDc3C1Xf{AL^uhk1wrV<;st!CGHJw~(n8}&hdt_Fk6`L9&QYGkcmp7{+wIF8 z4##dT+OQEY8jZ0&pRWyznwqxf9sX#ga3?EZC51vxYL%Q)y-~D!p}2cfjqojO9hsS# z?VNPj2t-9iMSH#8wOi}#2YS1P)23P@Ii1cBqNAfpuh-L(A~F5(i_)adB~>F%%wd*oQUYtb|gCudG6$-d<`l_ZC=fRG22vl&oPi(wj&l zye`TQIw?2FP6b9Iy{0$bFPAAl0a^D`6X0Ql^NI;--SxvFO>ZX?)8CkKBVJ9vADT*I zGXpdx7@*eAUZ8*Mdb-LO-izooQ}&LHvYy6q%y`ss9L#wn&izD-#d5P%q`iC|3txiy zHQ+jOp6B;dYHBKFWMoh#+8aUw-B78i3-2$=6trKYIhT@>asq3lJP`pNa+J}@C@|G- zxBJs~WV(&Z9PzZtV!`g<9J#)`>@9kuq=b@^k_dvM;b?EArPIx5dx&78+fBP-T@Nax z+Ep4bO6YHRr36CVeL(UyTRPXUK4=8HXrc*eAG|uIsKP3|C76iJ#b0>9d*+Nqi zJv1{gifXemsb_2!-F6CeS|+FD`7gkc!bLQ0uYo2RtQ%MgZb*@zVQ{ zkiODn{>$U>P!`mFh38+braSosbY;Q#h4+f|+zHE}pK6M3fF&6fXMC zGyK=STNFP#V0%&#T35vjx1Ym;U*eo!hIyA*LN^_;bSZHdH76v{nVcNz$$p-?l6}+- zZEzuO07(InYEAK9#2UsSpMo^TTtB+qy=NmLs5LT@@^Q@K%x0QtFj5=Z-DV4Q_)}>+ zLLY;EItXyP2y>H2TjQL35e5y zQjAI&dY6Er)QM#~VRI@wyT`_u`DyBap=CtcwKk208X-Vl^C417M2MG4rL+sv&!IX- zqYt5l-r0Z)7(WZ$v;~44T!c?UK-u8)9ci}P=^#uO!7JqYc_SkuF?j{zl|TW}&O1kVrL zxz%drYlw$JK#%fy1g)Zo$;$l>M<~xZ*x@=%n-Ax&Si?`*K{(iH{QjQJ?d{z-<5t$K(7HGLRkr^Gxv{q8E~v7}tO&00000NkvXXu0mjf DNC^_> literal 0 HcmV?d00001 diff --git a/gui/saverthread.cpp b/gui/saverthread.cpp index ac726a1..b7e3ebc 100644 --- a/gui/saverthread.cpp +++ b/gui/saverthread.cpp @@ -221,7 +221,7 @@ void SaverThread::run() { qputenv("TRACE_PATH", m_fileName.toLocal8Bit()); unsigned id = 0; - + qDebug()<<"saver thread!"; Trace::Open(); for (int i = 0; i < m_calls.count(); ++i) { ApiTraceCall *call = m_calls[i]; diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index 76c391e..3f15da2 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -374,6 +374,40 @@ + + + QDockWidget::AllDockWidgetFeatures + + + Errors + + + 8 + + + + + + + + Index + + + + + Name + + + + + Error + + + + + + + Exit @@ -514,6 +548,7 @@ stateDock vertexDataDock + errorsDock -- 2.43.0