Skip to content

Commit bc93fb7

Browse files
committed
src-level-debugging: misc. fixes.
- debuginfo: fix size() usage type in paths insert - debuginfo: use special MSVC defines to get math constants - Use QStringView instead of QStringRef, for compat reasons. - sourceswidget: don't use a hardcoded path
1 parent 8cf1724 commit bc93fb7

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

gui/qt/debugger/cdebughighlighter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <cassert>
77

8-
const QSet<QString> CDebugHighlighter::s_keywords{
8+
const QSet<QStringView> CDebugHighlighter::s_keywords{
99
QStringLiteral("_Align"),
1010
QStringLiteral("_At"),
1111
QStringLiteral("auto"),
@@ -151,7 +151,7 @@ void CDebugHighlighter::highlightBlock(const QString &text) {
151151
[[gnu::fallthrough]];
152152
case ParseState::PreprocessorInstruction:
153153
if (c == ' ' || c == '\t') {
154-
QStringRef instruction = text.midRef(start, i - start);
154+
QStringView instruction = text.mid(start, i - start);
155155
if (instruction == QStringLiteral("include")) {
156156
state = ParseState::PreprocessorInclude;
157157
} else if (instruction == QStringLiteral("if")) {
@@ -198,7 +198,7 @@ void CDebugHighlighter::highlightBlock(const QString &text) {
198198
if (i == text.length() ||
199199
((c < '0' || c > '9') && (c < 'A' || c > 'Z') &&
200200
c != '_' && (c < 'a' || c > 'z'))) {
201-
QStringRef token = text.midRef(start, i - start);
201+
QStringView token = text.mid(start, i - start);
202202
if (state == ParseState::NumberLiteral) {
203203
if (c == '.' || ((c == '+' || c == '-') && i > start &&
204204
(text[i - 1] == 'E' || text[i - 1] == 'e'))) {
@@ -240,7 +240,7 @@ void CDebugHighlighter::highlightBlock(const QString &text) {
240240
: m_sources->m_errorFormat);
241241
} else {
242242
setFormat(start, i - start,
243-
s_keywords.contains(token.toString()) ?
243+
s_keywords.contains(token) ?
244244
m_sources->m_keywordFormat :
245245
m_sources->m_identifierFormat);
246246
}

gui/qt/debugger/cdebughighlighter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CDebugHighlighter : public QSyntaxHighlighter {
2020

2121
private:
2222
SourcesWidget *m_sources;
23-
const static QSet<QString> s_keywords;
23+
const static QSet<QStringView> s_keywords;
2424
};
2525

2626
#endif

gui/qt/debugger/debuginfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ std::vector<std::uint32_t> Line::__parse(std::uint8_t address_size, const _Die &
15491549
dir = directories[file._M_directory_index]._M_path;
15501550
}
15511551
auto inserted = _M_paths.insert({ { unit_entry.attr(_At::DW_AT_comp_dir).str(),
1552-
dir, file._M_path }, size() });
1552+
dir, file._M_path }, static_cast<std::uint32_t>(size()) });
15531553
if (inserted.second) {
15541554
_M_files.emplace_back(inserted.first->first, file._M_MD5.data());
15551555
}

gui/qt/debugger/debuginfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifndef DEBUGINFO_H
22
#define DEBUGINFO_H
33

4+
/* Enable math constants on MSVC */
5+
#ifdef _MSC_VER
6+
#define _USE_MATH_DEFINES
7+
#endif
8+
49
#include <algorithm>
510
#include <array>
611
#include <cassert>

gui/qt/debugger/sourceswidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ SourcesWidget::SourcesWidget(QWidget *parent) : QWidget(parent) {
412412
SourcesWidget::~SourcesWidget() = default;
413413

414414
void SourcesWidget::selectDebugFile() {
415-
QString debugName = QFileDialog::getOpenFileName(this, tr("Open Debug File"), "/home/jacob/Programming/ez80/oiram/bin", tr("Debug File (*.debug)"));
415+
QString debugName = QFileDialog::getOpenFileName(this, tr("Open Debug File"), QString(), tr("Debug File (*.debug)"));
416416
if (debugName.isNull()) {
417417
return;
418418
}
@@ -590,7 +590,7 @@ void SourcesWidget::sourceContextMenu(const QPoint &pos) {
590590
QAction *action = menu.exec(sourceView->mapToGlobal(pos));
591591

592592
const auto &source = m_debugFile->line()
593-
.get(sourceView->objectName().midRef(QStringLiteral("sourceView").count()).toInt());
593+
.get(sourceView->objectName().mid(QStringLiteral("sourceView").count()).toInt());
594594
QTextCursor cursor = sourceView->cursorForPosition(pos);
595595
auto it = source.lines().upper_bound({ cursor.blockNumber() + 1, cursor.columnNumber() });
596596
if (it == source.lines().begin()) {
@@ -1166,7 +1166,7 @@ void SourcesWidget::VariableModel::fetchMore(const QModelIndex &parent) {
11661166
continue;
11671167
}
11681168
if (name.startsWith('*')) {
1169-
name = name.midRef(1) + "->";
1169+
name = name.mid(1) + "->";
11701170
} else {
11711171
name = name + '.';
11721172
}
@@ -1188,7 +1188,7 @@ int SourcesWidget::GlobalModel::commonPrefixLength(const QStringList &paths) {
11881188
if (!prefixLength) {
11891189
return maxPrefixLength;
11901190
}
1191-
QStringRef prefix = paths.first().leftRef(prefixLength);
1191+
QStringView prefix = paths.first().left(prefixLength);
11921192
for (int i = 1; i < paths.count(); i++) {
11931193
if (!paths.at(i).startsWith(prefix)) {
11941194
return maxPrefixLength;

0 commit comments

Comments
 (0)