Changeset View
Changeset View
Standalone View
Standalone View
src/backtracewidget.cpp
Show All 15 Lines | |||||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | * | 17 | * | ||
18 | ******************************************************************/ | 18 | ******************************************************************/ | ||
19 | 19 | | |||
20 | #include "backtracewidget.h" | 20 | #include "backtracewidget.h" | ||
21 | 21 | | |||
22 | #include <QLabel> | 22 | #include <QLabel> | ||
23 | #include <QScrollBar> | 23 | #include <QScrollBar> | ||
24 | #include <QDebug> | ||||
24 | 25 | | |||
25 | #include <KMessageBox> | 26 | #include <KMessageBox> | ||
26 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
28 | #include <KSyntaxHighlighting/SyntaxHighlighter> | ||||
29 | #include <KSyntaxHighlighting/Repository> | ||||
30 | #include <KSyntaxHighlighting/Theme> | ||||
31 | #include <KSyntaxHighlighting/Definition> | ||||
27 | #include <qdesktopservices.h> | 32 | #include <qdesktopservices.h> | ||
28 | 33 | | |||
29 | #include "drkonqi.h" | 34 | #include "drkonqi.h" | ||
30 | #include "backtraceratingwidget.h" | 35 | #include "backtraceratingwidget.h" | ||
31 | #include "crashedapplication.h" | 36 | #include "crashedapplication.h" | ||
32 | #include "backtracegenerator.h" | 37 | #include "backtracegenerator.h" | ||
33 | #include "parser/backtraceparser.h" | 38 | #include "parser/backtraceparser.h" | ||
34 | #include "drkonqi_globals.h" | 39 | #include "drkonqi_globals.h" | ||
35 | #include "debuggermanager.h" | 40 | #include "debuggermanager.h" | ||
36 | #include "gdbhighlighter.h" | | |||
37 | 41 | | |||
38 | static const char extraDetailsLabelMargin[] = " margin: 5px; "; | 42 | static const char extraDetailsLabelMargin[] = " margin: 5px; "; | ||
39 | 43 | | |||
40 | BacktraceWidget::BacktraceWidget(BacktraceGenerator *generator, QWidget *parent, | 44 | BacktraceWidget::BacktraceWidget(BacktraceGenerator *generator, QWidget *parent, | ||
41 | bool showToggleBacktrace) : | 45 | bool showToggleBacktrace) : | ||
42 | QWidget(parent), | 46 | QWidget(parent), | ||
43 | m_btGenerator(generator), | 47 | m_btGenerator(generator), | ||
44 | m_highlighter(nullptr) | 48 | m_highlighter(nullptr) | ||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 212 | if (m_btGenerator->state() == BacktraceGenerator::Loaded) { | |||
216 | } | 220 | } | ||
217 | if (!crashCursor.isNull()) { | 221 | if (!crashCursor.isNull()) { | ||
218 | crashCursor.movePosition(QTextCursor::Up, QTextCursor::MoveAnchor); | 222 | crashCursor.movePosition(QTextCursor::Up, QTextCursor::MoveAnchor); | ||
219 | ui.m_backtraceEdit->verticalScrollBar()->setValue(ui.m_backtraceEdit->cursorRect(crashCursor).top()); | 223 | ui.m_backtraceEdit->verticalScrollBar()->setValue(ui.m_backtraceEdit->cursorRect(crashCursor).top()); | ||
220 | } | 224 | } | ||
221 | 225 | | |||
222 | // highlight if possible | 226 | // highlight if possible | ||
223 | if (m_btGenerator->debugger().codeName() == QLatin1String("gdb")) { | 227 | if (m_btGenerator->debugger().codeName() == QLatin1String("gdb")) { | ||
224 | m_highlighter = new GdbHighlighter(ui.m_backtraceEdit->document(), | 228 | KSyntaxHighlighting::Repository repository; | ||
225 | m_btGenerator->parser()->parsedBacktraceLines()); | 229 | m_highlighter = new KSyntaxHighlighting::SyntaxHighlighter(ui.m_backtraceEdit->document()); | ||
230 | m_highlighter->setTheme((palette().color(QPalette::Base).lightness() < 128) | ||||
sitter: Ugh that's awkward. | |||||
231 | ? repository.defaultTheme(KSyntaxHighlighting::Repository::DarkTheme) | ||||
232 | : repository.defaultTheme(KSyntaxHighlighting::Repository::LightTheme)); | ||||
233 | | ||||
234 | const auto def = repository.definitionForName(QStringLiteral("GDB Backtrace")); | ||||
235 | m_highlighter->setDefinition(def); | ||||
226 | } | 236 | } | ||
227 | 237 | | |||
228 | BacktraceParser * btParser = m_btGenerator->parser(); | 238 | BacktraceParser * btParser = m_btGenerator->parser(); | ||
229 | m_backtraceRatingWidget->setUsefulness(btParser->backtraceUsefulness()); | 239 | m_backtraceRatingWidget->setUsefulness(btParser->backtraceUsefulness()); | ||
230 | 240 | | |||
231 | //Generate the text to put in the status widget (backtrace usefulness) | 241 | //Generate the text to put in the status widget (backtrace usefulness) | ||
232 | QString usefulnessText; | 242 | QString usefulnessText; | ||
233 | switch (btParser->backtraceUsefulness()) { | 243 | switch (btParser->backtraceUsefulness()) { | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
317 | 327 | | |||
318 | ui.m_reloadBacktraceButton->setEnabled(true); | 328 | ui.m_reloadBacktraceButton->setEnabled(true); | ||
319 | 329 | | |||
320 | emit stateChanged(); | 330 | emit stateChanged(); | ||
321 | } | 331 | } | ||
322 | 332 | | |||
323 | void BacktraceWidget::backtraceNewLine(const QString & line) | 333 | void BacktraceWidget::backtraceNewLine(const QString & line) | ||
324 | { | 334 | { | ||
325 | // We absolutely must not have a highlighter attached. The highlighter has | | |||
326 | // a static list of lines to highlight from. When we are loading lines | | |||
327 | // this static list does not match reality breaking text length expectations | | |||
328 | // and resulting in segfaults. | | |||
329 | Q_ASSERT(!m_highlighter); | | |||
330 | //While loading the backtrace (unparsed) a new line was sent from the debugger, append it | 335 | //While loading the backtrace (unparsed) a new line was sent from the debugger, append it | ||
331 | ui.m_backtraceEdit->append(line.trimmed()); | 336 | ui.m_backtraceEdit->append(line.trimmed()); | ||
332 | } | 337 | } | ||
333 | 338 | | |||
334 | void BacktraceWidget::copyClicked() | 339 | void BacktraceWidget::copyClicked() | ||
335 | { | 340 | { | ||
336 | ui.m_backtraceEdit->selectAll(); | 341 | ui.m_backtraceEdit->selectAll(); | ||
337 | ui.m_backtraceEdit->copy(); | 342 | ui.m_backtraceEdit->copy(); | ||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
Ugh that's awkward.