diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 212f00792..7517bc4b5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-24.04 strategy: matrix: - QT_VERSION: [5.15.2] + QT_VERSION: [5.15.*, 6.8.*] steps: - name: Install Dependencies run: sudo apt-get install -y libcapstone-dev libgraphviz-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a0d63e53..a827ea351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,25 @@ else() endif() endif() -find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core) +option(FORCE_QT5 "Force Building With Qt5 Even If Qt6 Is Present") +if(FORCE_QT5) + find_package(Qt5 REQUIRED COMPONENTS Core) + set(QT_VERSION_MAJOR 5) +else() + find_package(Qt6 COMPONENTS Core) + if(Qt6_FOUND) + set(QT_VERSION_MAJOR 6) + else() + find_package(Qt5 REQUIRED COMPONENTS Core) + set(QT_VERSION_MAJOR 5) + endif() +endif() + +if(DEFINED QT_VERSION_MAJOR) + message("Configured With Qt ${QT_VERSION_MAJOR}") +else() + message(FATAL_ERROR "No compatible version of Qt was found") +endif() include_directories("include") diff --git a/README.md b/README.md index a4675f4d7..9678893f9 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ edb is a cross platform AArch32/x86/x86-64 debugger. It was inspired by [Ollydbg](http://www.ollydbg.de/ "Ollydbg"), -but aims to function on AArch32, x86, and x86-64 as well as multiple OS's. Linux is the -only officially supported platform at the moment, but FreeBSD, OpenBSD, OSX and +but aims to function on AArch32, x86, and x86-64 as well as multiple OS's. **Linux is the +only officially supported platform at the moment**, but FreeBSD, OpenBSD, OSX and Windows ports are underway with varying degrees of functionality. ![Screenshot](https://raw.githubusercontent.com/wiki/eteran/edb-debugger/img/edb_interface-2019.png) @@ -39,7 +39,7 @@ depends on the following packages: Dependency | Version Required ------------------------------------------- | ---------------- GCC/Clang | Supporting C++17 -[Qt](http://www.qt.io/) | >= 5.15 +[Qt](http://www.qt.io/) | >= 5.15 or >= 6.8 [Capstone](http://www.capstone-engine.org/) | >= 3.0 [Graphviz](http://www.graphviz.org/) | >= 2.38.0 (Optional) diff --git a/cspell.config.yaml b/cspell.config.yaml index 28d9b49de..384946e9d 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -41,6 +41,7 @@ words: - qlonglong - qobject - qreal + - qsizetype - qsnprintf - Quadword - quadwords diff --git a/include/ArchProcessor.h b/include/ArchProcessor.h index a7192e537..fb1d0b3ed 100644 --- a/include/ArchProcessor.h +++ b/include/ArchProcessor.h @@ -12,11 +12,11 @@ #include "Status.h" #include "Types.h" #include +#include class QByteArray; class QMenu; class QString; -class QStringList; class State; class EDB_EXPORT ArchProcessor : public QObject { diff --git a/plugins/Analyzer/Analyzer.cpp b/plugins/Analyzer/Analyzer.cpp index d2f8ac418..75e6367ba 100644 --- a/plugins/Analyzer/Analyzer.cpp +++ b/plugins/Analyzer/Analyzer.cpp @@ -187,10 +187,18 @@ QMenu *Analyzer::menu(QWidget *parent) { menu_->addAction(tr("Show &Specified Functions"), this, &Analyzer::showSpecified); if (edb::v1::debugger_core) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Analyze %1's Region").arg(edb::v1::debugger_core->instructionPointer().toUpper()), QKeySequence(tr("Ctrl+A")), this, &Analyzer::doIpAnalysis); +#else menu_->addAction(tr("&Analyze %1's Region").arg(edb::v1::debugger_core->instructionPointer().toUpper()), this, &Analyzer::doIpAnalysis, QKeySequence(tr("Ctrl+A"))); +#endif } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Analyze Viewed Region"), QKeySequence(tr("Ctrl+Shift+A")), this, &Analyzer::doViewAnalysis); +#else menu_->addAction(tr("&Analyze Viewed Region"), this, &Analyzer::doViewAnalysis, QKeySequence(tr("Ctrl+Shift+A"))); +#endif // if we are dealing with a main window (and we are...) // add the dock object diff --git a/plugins/Analyzer/AnalyzerWidget.cpp b/plugins/Analyzer/AnalyzerWidget.cpp index b33107a5f..e0562dc2d 100644 --- a/plugins/Analyzer/AnalyzerWidget.cpp +++ b/plugins/Analyzer/AnalyzerWidget.cpp @@ -58,14 +58,12 @@ AnalyzerWidget::AnalyzerWidget(QWidget *parent, Qt::WindowFlags f) /** * @brief Renders a proportional color-coded map of analyzed functions across the current memory region. * - * @param event + * @param event The paint event that triggered this function. */ -void AnalyzerWidget::paintEvent(QPaintEvent *event) { +void AnalyzerWidget::paintEvent(QPaintEvent * /*event*/) { QElapsedTimer timer; timer.start(); - Q_UNUSED(event) - const std::shared_ptr region = edb::v1::current_cpu_view_region(); if (!region || region->size() == 0) { return; @@ -79,7 +77,7 @@ void AnalyzerWidget::paintEvent(QPaintEvent *event) { if (!cache_ || width() != cache_->width() || height() != cache_->height() || cacheNumFuncs_ != functions.size()) { cache_ = std::make_unique(width(), height()); - cacheNumFuncs_ = functions.size(); + cacheNumFuncs_ = static_cast(functions.size()); QPainter painter(cache_.get()); painter.fillRect(0, 0, width(), height(), QBrush(Qt::black)); @@ -156,7 +154,13 @@ void AnalyzerWidget::mousePressEvent(QMouseEvent *event) { const edb::address_t start = region->start(); const edb::address_t end = region->end(); - edb::address_t offset = start + static_cast(event->x() / byte_width); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const int x = qRound(event->position().x()); +#else + const int x = event->x(); +#endif + + edb::address_t offset = start + static_cast(x / byte_width); const edb::address_t address = qBound(start, offset, end - 1); edb::v1::jump_to_address(address); diff --git a/plugins/Analyzer/CMakeLists.txt b/plugins/Analyzer/CMakeLists.txt index 752c4b9b4..347f5b7c9 100644 --- a/plugins/Analyzer/CMakeLists.txt +++ b/plugins/Analyzer/CMakeLists.txt @@ -21,6 +21,6 @@ add_library(${PLUGIN_NAME} SHARED SpecifiedFunctions.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/Assembler/CMakeLists.txt b/plugins/Assembler/CMakeLists.txt index 195c253cb..415849e9a 100644 --- a/plugins/Assembler/CMakeLists.txt +++ b/plugins/Assembler/CMakeLists.txt @@ -5,7 +5,7 @@ set(PLUGIN_NAME "Assembler") find_package(Qt${QT_VERSION_MAJOR} REQUIRED Widgets Xml) -qt5_add_resources(QRC_SOURCES +qt_add_resources(QRC_SOURCES Assembler.qrc ) @@ -25,6 +25,6 @@ add_library(${PLUGIN_NAME} SHARED OptionsPage.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Xml edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets Qt::Xml edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/Backtrace/Backtrace.cpp b/plugins/Backtrace/Backtrace.cpp index e9f90433e..a319cee60 100644 --- a/plugins/Backtrace/Backtrace.cpp +++ b/plugins/Backtrace/Backtrace.cpp @@ -44,7 +44,11 @@ QMenu *Backtrace::menu(QWidget *parent) { menu_ = new QMenu(tr("Call Stack"), parent); // Ctrl + K shortcut, reminiscent of OllyDbg +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("Backtrace"), QKeySequence(tr("Ctrl+K")), this, &Backtrace::showMenu); +#else menu_->addAction(tr("Backtrace"), this, &Backtrace::showMenu, QKeySequence(tr("Ctrl+K"))); +#endif } return menu_; diff --git a/plugins/Backtrace/CMakeLists.txt b/plugins/Backtrace/CMakeLists.txt index a63603b03..f24ae92cf 100644 --- a/plugins/Backtrace/CMakeLists.txt +++ b/plugins/Backtrace/CMakeLists.txt @@ -15,6 +15,6 @@ add_library(${PLUGIN_NAME} SHARED DialogBacktrace.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/BinaryInfo/CMakeLists.txt b/plugins/BinaryInfo/CMakeLists.txt index ae812a6d9..b769d163c 100644 --- a/plugins/BinaryInfo/CMakeLists.txt +++ b/plugins/BinaryInfo/CMakeLists.txt @@ -28,6 +28,6 @@ add_library(${PLUGIN_NAME} SHARED symbols.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets PE ELF edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets PE ELF edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/BinaryInfo/ELFXX.cpp b/plugins/BinaryInfo/ELFXX.cpp index f15dca9fb..8726355d6 100644 --- a/plugins/BinaryInfo/ELFXX.cpp +++ b/plugins/BinaryInfo/ELFXX.cpp @@ -136,7 +136,6 @@ ELFXX::ELFXX(const std::shared_ptr ®ion) } } - /** * @brief Returns the size of the ELF header, including the program headers if they immediately follow the ELF header. * diff --git a/plugins/BinarySearcher/BinarySearcher.cpp b/plugins/BinarySearcher/BinarySearcher.cpp index 4963c50ea..cafd26ffc 100644 --- a/plugins/BinarySearcher/BinarySearcher.cpp +++ b/plugins/BinarySearcher/BinarySearcher.cpp @@ -33,7 +33,11 @@ QMenu *BinarySearcher::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("BinarySearcher"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Binary String Search"), QKeySequence(tr("Ctrl+F")), this, &BinarySearcher::showMenu); +#else menu_->addAction(tr("&Binary String Search"), this, &BinarySearcher::showMenu, QKeySequence(tr("Ctrl+F"))); +#endif } return menu_; diff --git a/plugins/BinarySearcher/CMakeLists.txt b/plugins/BinarySearcher/CMakeLists.txt index 2d3efde86..323af5d05 100644 --- a/plugins/BinarySearcher/CMakeLists.txt +++ b/plugins/BinarySearcher/CMakeLists.txt @@ -19,6 +19,6 @@ add_library(${PLUGIN_NAME} SHARED DialogResults.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/Bookmarks/BookmarkWidget.cpp b/plugins/Bookmarks/BookmarkWidget.cpp index 8cc1695a2..a315b62dc 100644 --- a/plugins/Bookmarks/BookmarkWidget.cpp +++ b/plugins/Bookmarks/BookmarkWidget.cpp @@ -69,7 +69,7 @@ void BookmarkWidget::on_tableView_doubleClicked(const QModelIndex &index) { items << tr("Code") << tr("Data") << tr("Stack"); bool ok; - const QString new_type = QInputDialog::getItem(ui.tableView, tr("Comment"), tr("Set Type:"), items, items.indexOf(old_type), false, &ok); + const QString new_type = QInputDialog::getItem(ui.tableView, tr("Comment"), tr("Set Type:"), items, static_cast(items.indexOf(old_type)), false, &ok); if (ok) { model_->setType(index, new_type); } @@ -261,7 +261,7 @@ void BookmarkWidget::on_tableView_customContextMenuRequested(const QPoint &pos) items << tr("Code") << tr("Data") << tr("Stack"); bool ok; - const QString new_type = QInputDialog::getItem(ui.tableView, tr("Comment"), tr("Set Type:"), items, items.indexOf(old_type), false, &ok); + const QString new_type = QInputDialog::getItem(ui.tableView, tr("Comment"), tr("Set Type:"), items, static_cast(items.indexOf(old_type)), false, &ok); if (ok) { model_->setType(index, new_type); } diff --git a/plugins/Bookmarks/BookmarksModel.cpp b/plugins/Bookmarks/BookmarksModel.cpp index 4e6484be6..cbdb84579 100644 --- a/plugins/Bookmarks/BookmarksModel.cpp +++ b/plugins/Bookmarks/BookmarksModel.cpp @@ -184,22 +184,20 @@ QModelIndex BookmarksModel::parent(const QModelIndex &index) const { /** * @brief Returns the number of bookmarks currently stored in the model. * - * @param parent - * @return + * @param parent The parent index. + * @return The number of bookmarks in the model. */ -int BookmarksModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return bookmarks_.size(); +int BookmarksModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(bookmarks_.size()); } /** * @brief Returns 3, representing the fixed Address, Type, and Comment columns. * - * @param parent - * @return + * @param parent The parent index. + * @return The number of columns in the model. */ -int BookmarksModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int BookmarksModel::columnCount(const QModelIndex & /*parent*/) const { return 3; } diff --git a/plugins/Bookmarks/CMakeLists.txt b/plugins/Bookmarks/CMakeLists.txt index 080407997..b29135740 100644 --- a/plugins/Bookmarks/CMakeLists.txt +++ b/plugins/Bookmarks/CMakeLists.txt @@ -15,6 +15,6 @@ add_library(${PLUGIN_NAME} SHARED BookmarkWidget.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/BreakpointManager/CMakeLists.txt b/plugins/BreakpointManager/CMakeLists.txt index f26c6dcb2..6a97e8d14 100644 --- a/plugins/BreakpointManager/CMakeLists.txt +++ b/plugins/BreakpointManager/CMakeLists.txt @@ -10,6 +10,6 @@ add_library(${PLUGIN_NAME} SHARED BreakpointManager.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/CheckVersion/CMakeLists.txt b/plugins/CheckVersion/CMakeLists.txt index 38a6d37bd..6187b0d43 100644 --- a/plugins/CheckVersion/CMakeLists.txt +++ b/plugins/CheckVersion/CMakeLists.txt @@ -13,6 +13,6 @@ add_library(${PLUGIN_NAME} SHARED OptionsPage.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets Qt::Network edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/DebuggerCore/CMakeLists.txt b/plugins/DebuggerCore/CMakeLists.txt index 1443f1980..f9df8c4d7 100644 --- a/plugins/DebuggerCore/CMakeLists.txt +++ b/plugins/DebuggerCore/CMakeLists.txt @@ -155,6 +155,6 @@ target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDES} ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets PE ELF edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets PE ELF edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/DebuggerCore/unix/linux/DebuggerCore.cpp b/plugins/DebuggerCore/unix/linux/DebuggerCore.cpp index ea780c782..ea6b9b970 100644 --- a/plugins/DebuggerCore/unix/linux/DebuggerCore.cpp +++ b/plugins/DebuggerCore/unix/linux/DebuggerCore.cpp @@ -933,7 +933,7 @@ Status DebuggerCore::open(const QString &path, const QString &cwd, const QList, "Can't copy string of QChar to shared memory"); #endif QString error = status.error(); - std::memcpy(sharedMem, error.constData(), std::min(sizeof(QChar) * error.size(), SharedMemSize - sizeof(QChar) /*prevent overwriting of last null*/)); + std::memcpy(sharedMem, error.constData(), std::min(sizeof(QChar) * error.size(), SharedMemSize - sizeof(QChar) /*prevent overwriting of last null*/)); // we should never get here! abort(); diff --git a/plugins/DebuggerCore/unix/linux/arch/x86-generic/PlatformState.cpp b/plugins/DebuggerCore/unix/linux/arch/x86-generic/PlatformState.cpp index 30a35d3d0..6aba2df3d 100644 --- a/plugins/DebuggerCore/unix/linux/arch/x86-generic/PlatformState.cpp +++ b/plugins/DebuggerCore/unix/linux/arch/x86-generic/PlatformState.cpp @@ -9,7 +9,7 @@ #include "Util.h" #include "string_hash.h" #include -#include +#include #include namespace DebuggerCorePlugin { @@ -924,9 +924,10 @@ Register PlatformState::value(const QString ®) const { } if (x86.gpr32Filled) { - QRegExp DRx("^dr([0-7])$"); - if (DRx.indexIn(regName) != -1) { - QChar digit = DRx.cap(1).at(0); + static const QRegularExpression DRx("^dr([0-7])$"); + const QRegularExpressionMatch match = DRx.match(regName); + if (match.hasMatch()) { + QChar digit = match.captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -941,9 +942,10 @@ Register PlatformState::value(const QString ®) const { } if (x87.filled) { - QRegExp Rx("^r([0-7])$"); - if (Rx.indexIn(regName) != -1) { - QChar digit = Rx.cap(1).at(0); + static const QRegularExpression Rx("^r([0-7])$"); + const QRegularExpressionMatch match = Rx.match(regName); + if (match.hasMatch()) { + QChar digit = match.captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -953,9 +955,10 @@ Register PlatformState::value(const QString ®) const { } if (x87.filled) { - QRegExp STx("^st\\(?([0-7])\\)?$"); - if (STx.indexIn(regName) != -1) { - QChar digit = STx.cap(1).at(0); + static const QRegularExpression STx("^st\\(?([0-7])\\)?$"); + const QRegularExpressionMatch match = STx.match(regName); + if (match.hasMatch()) { + QChar digit = match.captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -997,9 +1000,10 @@ Register PlatformState::value(const QString ®) const { } if (x87.filled) { - QRegExp MMx("^mm([0-7])$"); - if (MMx.indexIn(regName) != -1) { - QChar digit = MMx.cap(1).at(0); + static const QRegularExpression MMx("^mm([0-7])$"); + const QRegularExpressionMatch match = MMx.match(regName); + if (match.hasMatch()) { + QChar digit = match.captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -1009,10 +1013,11 @@ Register PlatformState::value(const QString ®) const { } if (avx.xmmFilledIA32) { - QRegExp XMMx("^xmm([0-9]|1[0-5])$"); - if (XMMx.indexIn(regName) != -1) { + static const QRegularExpression XMMx("^xmm([0-9]|1[0-5])$"); + const QRegularExpressionMatch match = XMMx.match(regName); + if (match.hasMatch()) { bool ok = false; - size_t i = XMMx.cap(1).toUShort(&ok); + size_t i = match.captured(1).toUShort(&ok); assert(ok); if (i >= IA32_XMM_REG_COUNT && !avx.xmmFilledAMD64) { return Register(); @@ -1025,10 +1030,11 @@ Register PlatformState::value(const QString ®) const { } if (avx.ymmFilled) { - QRegExp YMMx("^ymm([0-9]|1[0-5])$"); - if (YMMx.indexIn(regName) != -1) { + static const QRegularExpression YMMx("^ymm([0-9]|1[0-5])$"); + const QRegularExpressionMatch match = YMMx.match(regName); + if (match.hasMatch()) { bool ok = false; - size_t i = YMMx.cap(1).toUShort(&ok); + size_t i = match.captured(1).toUShort(&ok); assert(ok); if (ymmIndexValid(i)) { // May be invalid but legitimate for a disassembler: e.g. YMM13 but 32 bit mode return make_Register(regName, avx.ymm(i), Register::TYPE_SIMD); @@ -1331,9 +1337,10 @@ void PlatformState::setRegister(const Register ®) { { // TODO(eteran): these memcpy's which have the size set to the SOURCE and // not the dest look suspicious/potentially dangerous - QRegExp MMx("^mm([0-7])$"); - if (MMx.indexIn(regName) != -1) { - QChar digit = MMx.cap(1).at(0); + static const QRegularExpression MMx("^mm([0-7])$"); + const QRegularExpressionMatch match = MMx.match(regName); + if (match.hasMatch()) { + QChar digit = match.captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -1349,9 +1356,9 @@ void PlatformState::setRegister(const Register ®) { } { - QRegExp Rx("^r([0-7])$"); - if (Rx.indexIn(regName) != -1) { - QChar digit = Rx.cap(1).at(0); + static const QRegularExpression Rx("^r([0-7])$"); + if (Rx.match(regName).hasMatch()) { + QChar digit = Rx.match(regName).captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -1363,9 +1370,9 @@ void PlatformState::setRegister(const Register ®) { } { - QRegExp Rx("^st\\(?([0-7])\\)?$"); - if (Rx.indexIn(regName) != -1) { - QChar digit = Rx.cap(1).at(0); + static const QRegularExpression Rx("^st\\(?([0-7])\\)?$"); + if (Rx.match(regName).hasMatch()) { + QChar digit = Rx.match(regName).captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; @@ -1377,11 +1384,12 @@ void PlatformState::setRegister(const Register ®) { } { - QRegExp XMMx("^xmm([12]?[0-9]|3[01])$"); - if (XMMx.indexIn(regName) != -1) { + static const QRegularExpression XMMx("^xmm([12]?[0-9]|3[01])$"); + const QRegularExpressionMatch match = XMMx.match(regName); + if (match.hasMatch()) { const auto value = reg.value(); bool indexReadOK = false; - size_t i = XMMx.cap(1).toInt(&indexReadOK); + size_t i = match.captured(1).toInt(&indexReadOK); assert(indexReadOK && xmmIndexValid(i)); avx.zmmStorage[i].load(value); @@ -1390,11 +1398,12 @@ void PlatformState::setRegister(const Register ®) { } { - QRegExp YMMx("^ymm([12]?[0-9]|3[01])$"); - if (YMMx.indexIn(regName) != -1) { + static const QRegularExpression YMMx("^ymm([12]?[0-9]|3[01])$"); + const QRegularExpressionMatch match = YMMx.match(regName); + if (match.hasMatch()) { const auto value = reg.value(); bool indexReadOK = false; - size_t i = YMMx.cap(1).toInt(&indexReadOK); + size_t i = match.captured(1).toInt(&indexReadOK); assert(indexReadOK && ymmIndexValid(i)); avx.zmmStorage[i].load(value); @@ -1433,9 +1442,9 @@ void PlatformState::setRegister(const Register ®) { } { - QRegExp DRx("^dr([0-7])$"); - if (DRx.indexIn(regName) != -1) { - QChar digit = DRx.cap(1).at(0); + static const QRegularExpression DRx("^dr([0-7])$"); + if (DRx.match(regName).hasMatch()) { + QChar digit = DRx.match(regName).captured(1).at(0); assert(digit.isDigit()); char digitChar = digit.toLatin1(); size_t i = digitChar - '0'; diff --git a/plugins/DebuggerErrorConsole/CMakeLists.txt b/plugins/DebuggerErrorConsole/CMakeLists.txt index 287e6c24d..4c7063a05 100644 --- a/plugins/DebuggerErrorConsole/CMakeLists.txt +++ b/plugins/DebuggerErrorConsole/CMakeLists.txt @@ -10,6 +10,6 @@ add_library(${PLUGIN_NAME} SHARED Plugin.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/DumpState/CMakeLists.txt b/plugins/DumpState/CMakeLists.txt index 4c6e5ba32..666f85f38 100644 --- a/plugins/DumpState/CMakeLists.txt +++ b/plugins/DumpState/CMakeLists.txt @@ -13,6 +13,6 @@ add_library(${PLUGIN_NAME} SHARED OptionsPage.ui ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/DumpState/DumpState.cpp b/plugins/DumpState/DumpState.cpp index c4947859b..54adbcd62 100644 --- a/plugins/DumpState/DumpState.cpp +++ b/plugins/DumpState/DumpState.cpp @@ -127,7 +127,11 @@ QMenu *DumpState::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("DumpState"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Dump Current State"), QKeySequence(tr("Ctrl+D")), this, &DumpState::dumpCurrentState); +#else menu_->addAction(tr("&Dump Current State"), this, &DumpState::dumpCurrentState, QKeySequence(tr("Ctrl+D"))); +#endif } return menu_; diff --git a/plugins/FasLoader/CMakeLists.txt b/plugins/FasLoader/CMakeLists.txt index f95fd4415..72aa529ff 100644 --- a/plugins/FasLoader/CMakeLists.txt +++ b/plugins/FasLoader/CMakeLists.txt @@ -18,6 +18,6 @@ add_library(${PLUGIN_NAME} SHARED Fas/Symbol.hpp ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/FunctionFinder/CMakeLists.txt b/plugins/FunctionFinder/CMakeLists.txt index eb269a9c8..a61538ae2 100644 --- a/plugins/FunctionFinder/CMakeLists.txt +++ b/plugins/FunctionFinder/CMakeLists.txt @@ -18,6 +18,6 @@ add_library(${PLUGIN_NAME} SHARED ResultsModel.cpp ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/FunctionFinder/FunctionFinder.cpp b/plugins/FunctionFinder/FunctionFinder.cpp index 9790d1c3e..62ad2afe0 100644 --- a/plugins/FunctionFinder/FunctionFinder.cpp +++ b/plugins/FunctionFinder/FunctionFinder.cpp @@ -39,7 +39,11 @@ QMenu *FunctionFinder::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("FunctionFinder"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Function Finder"), QKeySequence(tr("Ctrl+Shift+F")), this, &FunctionFinder::showMenu); +#else menu_->addAction(tr("&Function Finder"), this, &FunctionFinder::showMenu, QKeySequence(tr("Ctrl+Shift+F"))); +#endif } return menu_; diff --git a/plugins/FunctionFinder/ResultsModel.cpp b/plugins/FunctionFinder/ResultsModel.cpp index b74ae2b3a..f1d75334b 100644 --- a/plugins/FunctionFinder/ResultsModel.cpp +++ b/plugins/FunctionFinder/ResultsModel.cpp @@ -142,7 +142,7 @@ QModelIndex ResultsModel::parent(const QModelIndex & /*index*/) const { */ int ResultsModel::rowCount(const QModelIndex & /*parent*/) const { - return results_.size(); + return static_cast(results_.size()); } /** diff --git a/plugins/HardwareBreakpoints/CMakeLists.txt b/plugins/HardwareBreakpoints/CMakeLists.txt index eac9392f2..6d84611b6 100644 --- a/plugins/HardwareBreakpoints/CMakeLists.txt +++ b/plugins/HardwareBreakpoints/CMakeLists.txt @@ -15,6 +15,6 @@ add_library(${PLUGIN_NAME} SHARED libHardwareBreakpoints.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp b/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp index 6017b632f..b68b0b386 100644 --- a/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp +++ b/plugins/HardwareBreakpoints/HardwareBreakpoints.cpp @@ -90,7 +90,11 @@ QMenu *HardwareBreakpoints::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("Hardware BreakpointManager"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Hardware Breakpoints"), QKeySequence(tr("Ctrl+Shift+H")), this, &HardwareBreakpoints::showMenu); +#else menu_->addAction(tr("&Hardware Breakpoints"), this, &HardwareBreakpoints::showMenu, QKeySequence(tr("Ctrl+Shift+H"))); +#endif } return menu_; diff --git a/plugins/HeapAnalyzer/CMakeLists.txt b/plugins/HeapAnalyzer/CMakeLists.txt index 274a36a7f..c3a512b36 100644 --- a/plugins/HeapAnalyzer/CMakeLists.txt +++ b/plugins/HeapAnalyzer/CMakeLists.txt @@ -15,6 +15,6 @@ add_library(${PLUGIN_NAME} SHARED ResultViewModel.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Concurrent edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets Qt::Concurrent edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/HeapAnalyzer/DialogHeap.cpp b/plugins/HeapAnalyzer/DialogHeap.cpp index 3f26a728c..a9ab79969 100644 --- a/plugins/HeapAnalyzer/DialogHeap.cpp +++ b/plugins/HeapAnalyzer/DialogHeap.cpp @@ -215,10 +215,10 @@ DialogHeap::DialogHeap(QWidget *parent, Qt::WindowFlags f) } } } - qDebug("[Heap Analyzer] Done Processing %d Nodes", nodes.size()); + qDebug("[Heap Analyzer] Done Processing %d Nodes", static_cast(nodes.size())); if (nodes.size() > MaxNodes) { - qDebug("[Heap Analyzer] Too Many Nodes! (%d)", nodes.size()); + qDebug("[Heap Analyzer] Too Many Nodes! (%d)", static_cast(nodes.size())); delete graph; return; } diff --git a/plugins/HeapAnalyzer/HeapAnalyzer.cpp b/plugins/HeapAnalyzer/HeapAnalyzer.cpp index 82424baf8..908f03194 100644 --- a/plugins/HeapAnalyzer/HeapAnalyzer.cpp +++ b/plugins/HeapAnalyzer/HeapAnalyzer.cpp @@ -39,7 +39,11 @@ QMenu *HeapAnalyzer::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("HeapAnalyzer"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Heap Analyzer"), QKeySequence(tr("Ctrl+H")), this, &HeapAnalyzer::showMenu); +#else menu_->addAction(tr("&Heap Analyzer"), this, &HeapAnalyzer::showMenu, QKeySequence(tr("Ctrl+H"))); +#endif } return menu_; diff --git a/plugins/HeapAnalyzer/ResultViewModel.cpp b/plugins/HeapAnalyzer/ResultViewModel.cpp index 9b514c8ff..593593eaa 100644 --- a/plugins/HeapAnalyzer/ResultViewModel.cpp +++ b/plugins/HeapAnalyzer/ResultViewModel.cpp @@ -182,9 +182,8 @@ QModelIndex ResultViewModel::parent(const QModelIndex &index) const { * @param parent The parent index. * @return The number of rows in the model. */ -int ResultViewModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return results_.size(); +int ResultViewModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(results_.size()); } /** @@ -193,8 +192,7 @@ int ResultViewModel::rowCount(const QModelIndex &parent) const { * @param parent The parent index. * @return The number of columns in the model. */ -int ResultViewModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int ResultViewModel::columnCount(const QModelIndex & /*parent*/) const { return 4; } diff --git a/plugins/InstructionInspector/CMakeLists.txt b/plugins/InstructionInspector/CMakeLists.txt index fbccd569e..0ed32496d 100644 --- a/plugins/InstructionInspector/CMakeLists.txt +++ b/plugins/InstructionInspector/CMakeLists.txt @@ -10,6 +10,6 @@ add_library(${PLUGIN_NAME} SHARED Plugin.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/InstructionInspector/Plugin.cpp b/plugins/InstructionInspector/Plugin.cpp index 4e850a761..77e856dbc 100644 --- a/plugins/InstructionInspector/Plugin.cpp +++ b/plugins/InstructionInspector/Plugin.cpp @@ -757,7 +757,7 @@ QString normalizeOBJDUMP(const QString &text, int bits) { // left removes colon addr = addr.left(addr.size() - 1).rightJustified(bits / 4, '0'); bytes = bytes.trimmed().toUpper(); - disasm = disasm.trimmed().replace(QRegExp(" +"), " "); + disasm = disasm.trimmed().replace(QRegularExpression(" +"), " "); #if defined(EDB_ARM32) // ARM objdump prints instruction bytes as a word instead of separate bytes. We won't @@ -824,11 +824,11 @@ std::string runOBJDUMP(const std::vector &bytes, edb::address_t ad } const auto output = QString::fromUtf8(process.readAllStandardOutput()).split('\n'); - const auto addrStr = address.toHexString().toLower().replace(QRegExp("^0+"), ""); + const auto addrStr = address.toHexString().toLower().replace(QRegularExpression("^0+"), ""); QString result; for (auto &line : output) { - if (line.contains(QRegExp("^ *" + addrStr + ":\t[^\t]+\t"))) { + if (line.contains(QRegularExpression("^ *" + addrStr + ":\t[^\t]+\t"))) { result = line; break; } @@ -866,7 +866,7 @@ QString normalizeNDISASM(const QString &text, int bits) { auto lines = text.split('\n'); Q_ASSERT(!lines.isEmpty()); - auto parts = lines.takeFirst().replace(QRegExp(" +"), "\t").split('\t'); + auto parts = lines.takeFirst().replace(QRegularExpression(" +"), "\t").split('\t'); if (parts.size() != 3) { return text + " ; unexpected format 1"; @@ -881,15 +881,15 @@ QString normalizeNDISASM(const QString &text, int bits) { // connect the rest of lines to bytes for (auto &line : lines) { - if (!line.contains(QRegExp("^ +-[0-9a-fA-F]+$"))) { + if (!line.contains(QRegularExpression("^ +-[0-9a-fA-F]+$"))) { return text + " ; unexpected format 2"; } line = line.trimmed(); - bytes += line.rightRef(line.size() - 1); // remove leading '-' + bytes += line.right(line.size() - 1); // remove leading '-' } - bytes.replace(QRegExp("(..)"), "\\1 "); + bytes.replace(QRegularExpression("(..)"), "\\1 "); return addr + " " + bytes.trimmed() + " " + disasm.trimmed(); } @@ -934,7 +934,7 @@ std::string runNDISASM(const std::vector &bytes, edb::address_t ad QString result = output.takeFirst(); for (auto &line : output) { - if (line.contains(QRegExp("^ +-[0-9a-fA-F]+$"))) { + if (line.contains(QRegularExpression("^ +-[0-9a-fA-F]+$"))) { result += "\n" + line; } else { break; @@ -959,17 +959,18 @@ std::string runNDISASM(const std::vector &bytes, edb::address_t ad */ std::pair normalizeOBJCONV(const QString &text, int bits) { - QRegExp expectedFormat("^ +([^;]+); ([0-9a-fA-F]+) _ (.*)"); - if (expectedFormat.indexIn(text, 0) == -1) { + static const QRegularExpression expectedFormat("^ +([^;]+); ([0-9a-fA-F]+) _ (.*)"); + const QRegularExpressionMatch expectedMatch = expectedFormat.match(text); + if (!expectedMatch.hasMatch()) { throw NormalizeFailure{}; } - const auto addr = expectedFormat.cap(2).rightJustified(bits / 4, '0'); - auto bytes = expectedFormat.cap(3).trimmed(); - const auto disasm = expectedFormat.cap(1).trimmed().replace(QRegExp(" +"), " "); + const auto addr = expectedMatch.captured(2).rightJustified(bits / 4, '0'); + auto bytes = expectedMatch.captured(3).trimmed(); + const auto disasm = expectedMatch.captured(1).trimmed().replace(QRegularExpression(" +"), " "); const auto result = addr + " " + bytes + " " + disasm; - bytes.replace(QRegExp("[^0-9a-fA-F]"), ""); + bytes.replace(QRegularExpression("[^0-9a-fA-F]"), ""); const std::size_t insnLength = bytes.length() / 2; return {result, insnLength}; } @@ -1190,19 +1191,19 @@ std::string runOBJCONV(std::vector bytes, edb::address_t address) Instruction, } mode = LookingFor::FunctionBegin; - const QString addrFormatted = address.toHexString().toUpper().replace(QRegExp("^0+"), ""); - const QString addrTruncatedFormatted = (address & UINT32_MAX).toHexString().toUpper().replace(QRegExp("^0+"), ""); + const QString addrFormatted = address.toHexString().toUpper().replace(QRegularExpression("^0+"), ""); + const QString addrTruncatedFormatted = (address & UINT32_MAX).toHexString().toUpper().replace(QRegularExpression("^0+"), ""); for (const QByteArray &byteString : lines) { const auto line = QString::fromUtf8(byteString); switch (mode) { case LookingFor::FunctionBegin: - if (line.contains(QRegExp("^; Instruction set:"))) { + if (line.contains(QRegularExpression("^; Instruction set:"))) { result += line + '\n'; continue; } - if (line.contains(QRegExp("^SECTION.* execute"))) { + if (line.contains(QRegularExpression("^SECTION.* execute"))) { mode = LookingFor::Instruction; continue; } @@ -1220,7 +1221,7 @@ std::string runOBJCONV(std::vector bytes, edb::address_t address) result += line + '\n'; } - if (line.contains(QRegExp(" +[^;]+; 0*" + addrFormatted + " _")) || line.contains(QRegExp(" +[^;]+; 0*" + addrTruncatedFormatted + " _"))) { // XXX: objconv truncates all addresses to 32 bits + if (line.contains(QRegularExpression(" +[^;]+; 0*" + addrFormatted + " _")) || line.contains(QRegularExpression(" +[^;]+; 0*" + addrTruncatedFormatted + " _"))) { // XXX: objconv truncates all addresses to 32 bits try { QString normalized; std::size_t insnLength; @@ -1240,7 +1241,7 @@ std::string runOBJCONV(std::vector bytes, edb::address_t address) } } - if (line.contains(QRegExp("^ +db "))) { + if (line.contains(QRegularExpression("^ +db "))) { auto lines = result.split('\n'); for (int i = 0; i < result.size(); ++i) { if (lines[i].startsWith("; Instruction set:")) { diff --git a/plugins/ODbgRegisterView/CMakeLists.txt b/plugins/ODbgRegisterView/CMakeLists.txt index 865ae1537..ffc154ca5 100644 --- a/plugins/ODbgRegisterView/CMakeLists.txt +++ b/plugins/ODbgRegisterView/CMakeLists.txt @@ -80,6 +80,6 @@ target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDES} ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/ODbgRegisterView/DialogEditSimdRegister.cpp b/plugins/ODbgRegisterView/DialogEditSimdRegister.cpp index e90548bd1..af9c6adad 100644 --- a/plugins/ODbgRegisterView/DialogEditSimdRegister.cpp +++ b/plugins/ODbgRegisterView/DialogEditSimdRegister.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -329,18 +328,27 @@ void DialogEditSimdRegister::setValue(const Register &value) { assert(value.bitSize() <= 8 * sizeof(value_)); reg_ = value; util::mark_memory(&value_, value_.size()); - if (QRegExp("mm[0-7]").exactMatch(reg_.name())) { + + static const QRegularExpression MMXx("^mm([0-7])$"); + static const QRegularExpression XMMx("^xmm([0-9]+)$"); + static const QRegularExpression YMMx("^ymm([0-9]+)$"); + + const QRegularExpressionMatch mmxMatch = MMXx.match(reg_.name()); + const QRegularExpressionMatch xmmMatch = XMMx.match(reg_.name()); + const QRegularExpressionMatch ymmMatch = YMMx.match(reg_.name()); + + if (mmxMatch.hasMatch()) { const auto value = reg_.value(); std::memcpy(&value_, &value, sizeof(value)); hideColumns(MMX_FIRST_COL); // MMX registers are never used in float computations, so hide useless rows hideRows(FLOATS32_ROW); hideRows(FLOATS64_ROW); - } else if (QRegExp("xmm[0-9]+").exactMatch(reg_.name())) { + } else if (xmmMatch.hasMatch()) { const auto value = reg_.value(); std::memcpy(&value_, &value, sizeof(value)); hideColumns(XMM_FIRST_COL); - } else if (QRegExp("ymm[0-9]+").exactMatch(reg_.name())) { + } else if (ymmMatch.hasMatch()) { const auto value = reg_.value(); std::memcpy(&value_, &value, sizeof(value)); hideColumns(YMM_FIRST_COL); diff --git a/plugins/ODbgRegisterView/FieldWidget.cpp b/plugins/ODbgRegisterView/FieldWidget.cpp index e848499d2..20dbcad03 100644 --- a/plugins/ODbgRegisterView/FieldWidget.cpp +++ b/plugins/ODbgRegisterView/FieldWidget.cpp @@ -49,13 +49,13 @@ FieldWidget::FieldWidget(int fieldWidth, const QModelIndex &index, QWidget *pare FieldWidget::FieldWidget(int fieldWidth, const QString &fixedText, QWidget *parent, Qt::WindowFlags f) : QLabel(fixedText, parent, f), fieldWidth_(fieldWidth) { - init(fieldWidth); // NOTE: fieldWidth!=fixedText.length() in general + init(fieldWidth); // NOTE: fieldWidth!=fixedText.size() in general } FieldWidget::FieldWidget(const QString &fixedText, QWidget *parent, Qt::WindowFlags f) - : QLabel(fixedText, parent, f), fieldWidth_(fixedText.length()) { + : QLabel(fixedText, parent, f), fieldWidth_(static_cast(fixedText.size())) { - init(fixedText.length()); + init(static_cast(fixedText.size())); } int FieldWidget::fieldWidth() const { diff --git a/plugins/ODbgRegisterView/GprEdit.cpp b/plugins/ODbgRegisterView/GprEdit.cpp index cba5f0661..1c1da2644 100644 --- a/plugins/ODbgRegisterView/GprEdit.cpp +++ b/plugins/ODbgRegisterView/GprEdit.cpp @@ -131,7 +131,12 @@ QSize GprEdit::sizeHint() const { const auto textMargins = this->textMargins(); const auto contentsMargins = this->contentsMargins(); int customWidth = charWidth * naturalWidthInChars_ + textMargins.left() + contentsMargins.left() + textMargins.right() + contentsMargins.right() + 1 * charWidth; // additional char to make edit field not too tight + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QSize(customWidth, baseHint.height()); +#else return QSize(customWidth, baseHint.height()).expandedTo(QApplication::globalStrut()); +#endif } } diff --git a/plugins/ODbgRegisterView/NumberEdit.cpp b/plugins/ODbgRegisterView/NumberEdit.cpp index 66870ca35..8615a6139 100644 --- a/plugins/ODbgRegisterView/NumberEdit.cpp +++ b/plugins/ODbgRegisterView/NumberEdit.cpp @@ -39,7 +39,11 @@ QSize NumberEdit::sizeHint() const { const auto contentsMargins = this->contentsMargins(); int customWidth = charWidth * naturalWidthInChars_ + textMargins.left() + contentsMargins.left() + textMargins.right() + contentsMargins.right(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QSize(customWidth, baseHint.height()); +#else return QSize(customWidth, baseHint.height()).expandedTo(QApplication::globalStrut()); +#endif } } diff --git a/plugins/ODbgRegisterView/RegisterGroup.cpp b/plugins/ODbgRegisterView/RegisterGroup.cpp index 2faf969bb..77f7a7df5 100644 --- a/plugins/ODbgRegisterView/RegisterGroup.cpp +++ b/plugins/ODbgRegisterView/RegisterGroup.cpp @@ -46,7 +46,11 @@ void RegisterGroup::showMenu(const QPoint &position, const QList &add void RegisterGroup::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::RightButton) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + showMenu(event->globalPosition().toPoint(), menuItems_); +#else showMenu(event->globalPos(), menuItems_); +#endif } else { event->ignore(); } diff --git a/plugins/ODbgRegisterView/RegisterView.cpp b/plugins/ODbgRegisterView/RegisterView.cpp index dff3e7d0f..4bd263014 100644 --- a/plugins/ODbgRegisterView/RegisterView.cpp +++ b/plugins/ODbgRegisterView/RegisterView.cpp @@ -160,7 +160,11 @@ void ODBRegView::mousePressEvent(QMouseEvent *event) { switch (event->button()) { case Qt::RightButton: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + showMenu(event->globalPosition().toPoint()); +#else showMenu(event->globalPos()); +#endif break; case Qt::LeftButton: for (const auto field : valueFields()) { @@ -321,12 +325,12 @@ void ODBRegView::copyAllRegisters() const { const QString fieldText = field->text(); if (field->alignment() == Qt::AlignRight) { const int fwidth = field->fieldWidth(); - const int spaceWidth = fwidth - fieldText.length(); + const int spaceWidth = fwidth - static_cast(fieldText.size()); text += QString(spaceWidth, ' '); textColumn += spaceWidth; } text += fieldText; - textColumn += fieldText.length(); + textColumn += static_cast(fieldText.size()); } QApplication::clipboard()->setText(text.trimmed()); diff --git a/plugins/ODbgRegisterView/ValueField.cpp b/plugins/ODbgRegisterView/ValueField.cpp index fa52e7c25..c01b8a56b 100644 --- a/plugins/ODbgRegisterView/ValueField.cpp +++ b/plugins/ODbgRegisterView/ValueField.cpp @@ -302,10 +302,17 @@ void ValueField::updatePalette() { QLabel::update(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void ValueField::enterEvent(QEnterEvent *) { + hovered_ = true; + updatePalette(); +} +#else void ValueField::enterEvent(QEvent *) { hovered_ = true; updatePalette(); } +#endif void ValueField::leaveEvent(QEvent *) { hovered_ = false; @@ -333,7 +340,11 @@ void ValueField::mousePressEvent(QMouseEvent *event) { } if (event->button() == Qt::RightButton && event->type() != QEvent::MouseButtonDblClick) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + showMenu(event->globalPosition().toPoint()); +#else showMenu(event->globalPos()); +#endif } } diff --git a/plugins/ODbgRegisterView/ValueField.h b/plugins/ODbgRegisterView/ValueField.h index e8a0df300..7f795eeb9 100644 --- a/plugins/ODbgRegisterView/ValueField.h +++ b/plugins/ODbgRegisterView/ValueField.h @@ -41,7 +41,11 @@ class ValueField : public FieldWidget { [[nodiscard]] RegisterViewModelBase::Model *model() const; [[nodiscard]] bool changed() const; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void enterEvent(QEnterEvent *) override; +#else void enterEvent(QEvent *) override; +#endif void leaveEvent(QEvent *) override; void mousePressEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; diff --git a/plugins/ODbgRegisterView/arch/x86-generic/Float80Edit.cpp b/plugins/ODbgRegisterView/arch/x86-generic/Float80Edit.cpp index 32f2c93be..b6cab1a3a 100644 --- a/plugins/ODbgRegisterView/arch/x86-generic/Float80Edit.cpp +++ b/plugins/ODbgRegisterView/arch/x86-generic/Float80Edit.cpp @@ -23,7 +23,11 @@ void Float80Edit::setValue(edb::value80 input) { QSize Float80Edit::sizeHint() const { const auto baseHint = QLineEdit::sizeHint(); // Default size hint gives space for about 15-20 chars. We need about 30. +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return QSize(baseHint.width() * 2, baseHint.height()); +#else return QSize(baseHint.width() * 2, baseHint.height()).expandedTo(QApplication::globalStrut()); +#endif } void Float80Edit::focusOutEvent(QFocusEvent *e) { diff --git a/plugins/ODbgRegisterView/arch/x86-generic/x86FPUValueField.cpp b/plugins/ODbgRegisterView/arch/x86-generic/x86FPUValueField.cpp index 879978547..1367b4420 100644 --- a/plugins/ODbgRegisterView/arch/x86-generic/x86FPUValueField.cpp +++ b/plugins/ODbgRegisterView/arch/x86-generic/x86FPUValueField.cpp @@ -32,12 +32,12 @@ FpuValueField::FpuValueField(int fieldWidth, const QModelIndex ®ValueIndex, c Q_ASSERT(group); Q_ASSERT(commentWidget); - showAsRawActionIndex_ = menuItems_.size(); + showAsRawActionIndex_ = static_cast(menuItems_.size()); menuItems_.push_back(new_action(tr("View FPU as raw values"), this, [this](bool) { showFPUAsRaw(); })); - showAsFloatActionIndex_ = menuItems_.size(); + showAsFloatActionIndex_ = static_cast(menuItems_.size()); menuItems_.push_back(new_action(tr("View FPU as floats"), this, [this](bool) { showFPUAsFloat(); })); diff --git a/plugins/ODbgRegisterView/arch/x86-generic/x86Groups.cpp b/plugins/ODbgRegisterView/arch/x86-generic/x86Groups.cpp index d0d049f03..1976a7190 100644 --- a/plugins/ODbgRegisterView/arch/x86-generic/x86Groups.cpp +++ b/plugins/ODbgRegisterView/arch/x86-generic/x86Groups.cpp @@ -473,7 +473,7 @@ RegisterGroup *create_fpu_last_op(RegisterViewModelBase::Model *model, QWidget * // In 64-bit mode, since segments are not maintained, we'll just show offsets const auto FIPwidth = FDPIndex.data(Model::FixedLengthRole).toInt(); const auto segWidth = FIPwidth == 8 /*8chars=>32bit*/ ? 4 : 0; - const auto segColumn = lastInsnLabel.length() + 1; + const auto segColumn = static_cast(lastInsnLabel.size()) + 1; if (segWidth) { // these two must be inserted first, because seg & offset value fields overlap these labels @@ -555,7 +555,7 @@ RegisterGroup *create_fpu_last_op(RegisterViewModelBase::Model *model, QWidget * }; const auto FOPValueField = new ValueField(5, FOPIndex, FOPFormatter, group); - group->insert(lastOpcodeRow, lastOpcodeLabel.length() + 1, FOPValueField); + group->insert(lastOpcodeRow, static_cast(lastOpcodeLabel.size()) + 1, FOPValueField); static const auto FOPTooltip = tr("Last FPU opcode"); lastOpcodeLabelField->setToolTip(FOPTooltip); @@ -679,7 +679,7 @@ RegisterGroup *create_debug_group(RegisterViewModelBase::Model *model, QWidget * column += valueWidth + 2; const QString bsName = QStringLiteral("BS"); - const auto bsWidth = bsName.length(); + const auto bsWidth = static_cast(bsName.size()); const auto BSNameField = new FieldWidget(bsName, group); const auto BSTooltip = tr("Single Step") + " (BS)"; BSNameField->setToolTip(BSTooltip); @@ -702,8 +702,8 @@ RegisterGroup *create_debug_group(RegisterViewModelBase::Model *model, QWidget * group->insert(row, column, new ValueField(valueWidth, value_index(dr7Index), group)); column += valueWidth + 2; { - const QString leName = "LE"; - const auto leWidth = leName.length(); + const QString leName = QStringLiteral("LE"); + const auto leWidth = static_cast(leName.size()); const auto LENameField = new FieldWidget(leName, group); const auto LETooltip = tr("Local Exact Breakpoint Enable"); LENameField->setToolTip(LETooltip); @@ -719,8 +719,8 @@ RegisterGroup *create_debug_group(RegisterViewModelBase::Model *model, QWidget * } { - const QString geName = "GE"; - const auto geWidth = geName.length(); + const QString geName = QStringLiteral("GE"); + const auto geWidth = static_cast(geName.size()); const auto GENameField = new FieldWidget(geName, group); const auto GETooltip = tr("Global Exact Breakpoint Enable"); GENameField->setToolTip(GETooltip); @@ -757,7 +757,7 @@ RegisterGroup *create_mxcsr(RegisterViewModelBase::Model *model, QWidget *parent const int maskRow = rndRow; group->insert(mxcsrRow, column, new FieldWidget(mxcsrName, group)); - column += mxcsrName.length() + 1; + column += static_cast(mxcsrName.size()) + 1; const auto mxcsrIndex = find_model_register(catIndex, "MXCSR", ModelValueColumn); const auto mxcsrValueWidth = mxcsrIndex.data(Model::FixedLengthRole).toInt(); assert(mxcsrValueWidth > 0); @@ -771,7 +771,7 @@ RegisterGroup *create_mxcsr(RegisterViewModelBase::Model *model, QWidget *parent const auto fzColumn = column; const auto fzNameField = new FieldWidget(fzName, group); group->insert(fzRow, fzColumn, fzNameField); - column += fzName.length() + 1; + column += static_cast(fzName.size()) + 1; const auto fzIndex = find_model_register(mxcsrIndex, "FZ", ModelValueColumn); const auto fzValueWidth = 1; const auto fzValueField = new ValueField(fzValueWidth, fzIndex, group); @@ -779,7 +779,7 @@ RegisterGroup *create_mxcsr(RegisterViewModelBase::Model *model, QWidget *parent column += fzValueWidth + 1; const auto dazNameField = new FieldWidget(dazName, group); group->insert(dazRow, column, dazNameField); - column += dazName.length() + 1; + column += static_cast(dazName.size()) + 1; const auto dazIndex = find_model_register(mxcsrIndex, "DAZ", ModelValueColumn); const auto dazValueWidth = 1; const auto dazValueField = new ValueField(dazValueWidth, dazIndex, group); @@ -789,12 +789,12 @@ RegisterGroup *create_mxcsr(RegisterViewModelBase::Model *model, QWidget *parent group->insert(excRow, column, new FieldWidget(excName, group)); const QString maskName = "Mask"; group->insert(maskRow, column, new FieldWidget(maskName, group)); - column += maskName.length() + 1; + column += static_cast(maskName.size()) + 1; add_puozdi(group, mxcsrIndex, mxcsrIndex, excRow - 1, column); const auto rndNameColumn = fzColumn; const QString rndName = "Rnd"; group->insert(rndRow, rndNameColumn, new FieldWidget(rndName, group)); - const auto rndColumn = rndNameColumn + rndName.length() + 1; + const auto rndColumn = rndNameColumn + static_cast(rndName.size()) + 1; add_rounding_mode(group, find_model_register(mxcsrIndex, "RC", ModelValueColumn), rndRow, rndColumn); { diff --git a/plugins/OpcodeSearcher/CMakeLists.txt b/plugins/OpcodeSearcher/CMakeLists.txt index b92847405..977d47a55 100644 --- a/plugins/OpcodeSearcher/CMakeLists.txt +++ b/plugins/OpcodeSearcher/CMakeLists.txt @@ -18,6 +18,6 @@ add_library(${PLUGIN_NAME} SHARED ResultsModel.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/OpcodeSearcher/OpcodeSearcher.cpp b/plugins/OpcodeSearcher/OpcodeSearcher.cpp index 4a153b948..a5b3f5068 100644 --- a/plugins/OpcodeSearcher/OpcodeSearcher.cpp +++ b/plugins/OpcodeSearcher/OpcodeSearcher.cpp @@ -39,7 +39,11 @@ QMenu *OpcodeSearcher::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("OpcodeSearcher"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Opcode Search"), QKeySequence(tr("Ctrl+O")), this, &OpcodeSearcher::showMenu); +#else menu_->addAction(tr("&Opcode Search"), this, &OpcodeSearcher::showMenu, QKeySequence(tr("Ctrl+O"))); +#endif } return menu_; diff --git a/plugins/OpcodeSearcher/ResultsModel.cpp b/plugins/OpcodeSearcher/ResultsModel.cpp index 7c52bda06..257263376 100644 --- a/plugins/OpcodeSearcher/ResultsModel.cpp +++ b/plugins/OpcodeSearcher/ResultsModel.cpp @@ -125,9 +125,8 @@ QModelIndex ResultsModel::parent(const QModelIndex &index) const { * @param parent The parent index. * @return The number of rows in the model. */ -int ResultsModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return results_.size(); +int ResultsModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(results_.size()); } /** @@ -136,8 +135,7 @@ int ResultsModel::rowCount(const QModelIndex &parent) const { * @param parent The parent index. * @return The number of columns in the model. */ -int ResultsModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int ResultsModel::columnCount(const QModelIndex & /*parent*/) const { return 2; } diff --git a/plugins/ProcessProperties/CMakeLists.txt b/plugins/ProcessProperties/CMakeLists.txt index b408c6a85..5a291a3f1 100644 --- a/plugins/ProcessProperties/CMakeLists.txt +++ b/plugins/ProcessProperties/CMakeLists.txt @@ -21,6 +21,6 @@ add_library(${PLUGIN_NAME} SHARED ResultsModel.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets Qt::Network edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/ProcessProperties/ProcessProperties.cpp b/plugins/ProcessProperties/ProcessProperties.cpp index 48dbab480..80926d148 100644 --- a/plugins/ProcessProperties/ProcessProperties.cpp +++ b/plugins/ProcessProperties/ProcessProperties.cpp @@ -44,8 +44,13 @@ QMenu *ProcessProperties::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("Process Properties"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Process Properties"), QKeySequence(tr("Ctrl+P")), this, &ProcessProperties::showMenu); + menu_->addAction(tr("Process &Strings"), QKeySequence(tr("Ctrl+S")), dialog_, SLOT(on_btnStrings_clicked())); +#else menu_->addAction(tr("&Process Properties"), this, &ProcessProperties::showMenu, QKeySequence(tr("Ctrl+P"))); menu_->addAction(tr("Process &Strings"), dialog_, SLOT(on_btnStrings_clicked()), QKeySequence(tr("Ctrl+S"))); +#endif } return menu_; diff --git a/plugins/ProcessProperties/ResultsModel.cpp b/plugins/ProcessProperties/ResultsModel.cpp index 5f1bb15bf..280a31229 100644 --- a/plugins/ProcessProperties/ResultsModel.cpp +++ b/plugins/ProcessProperties/ResultsModel.cpp @@ -139,9 +139,8 @@ QModelIndex ResultsModel::parent(const QModelIndex &index) const { * @param parent The parent index. * @return The number of rows in the model. */ -int ResultsModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return results_.size(); +int ResultsModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(results_.size()); } /** @@ -150,8 +149,7 @@ int ResultsModel::rowCount(const QModelIndex &parent) const { * @param parent The parent index. * @return The number of columns in the model. */ -int ResultsModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int ResultsModel::columnCount(const QModelIndex & /*parent*/) const { return 3; } diff --git a/plugins/ROPTool/CMakeLists.txt b/plugins/ROPTool/CMakeLists.txt index 202f9ff3b..f107694ea 100644 --- a/plugins/ROPTool/CMakeLists.txt +++ b/plugins/ROPTool/CMakeLists.txt @@ -18,6 +18,6 @@ add_library(${PLUGIN_NAME} SHARED ResultsModel.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/ROPTool/ROPTool.cpp b/plugins/ROPTool/ROPTool.cpp index 6d44ab8f3..f0b8247ae 100644 --- a/plugins/ROPTool/ROPTool.cpp +++ b/plugins/ROPTool/ROPTool.cpp @@ -39,7 +39,11 @@ QMenu *ROPTool::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("ROPTool"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&ROP Tool"), QKeySequence(tr("Ctrl+Alt+R")), this, &ROPTool::showMenu); +#else menu_->addAction(tr("&ROP Tool"), this, &ROPTool::showMenu, QKeySequence(tr("Ctrl+Alt+R"))); +#endif } return menu_; diff --git a/plugins/ROPTool/ResultsModel.cpp b/plugins/ROPTool/ResultsModel.cpp index c1e423a8b..9777dff32 100644 --- a/plugins/ROPTool/ResultsModel.cpp +++ b/plugins/ROPTool/ResultsModel.cpp @@ -125,9 +125,8 @@ QModelIndex ResultsModel::parent(const QModelIndex &index) const { * @param parent The parent index. * @return The number of rows in the model. */ -int ResultsModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return results_.size(); +int ResultsModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(results_.size()); } /** @@ -136,8 +135,7 @@ int ResultsModel::rowCount(const QModelIndex &parent) const { * @param parent The parent index. * @return The number of columns in the model. */ -int ResultsModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int ResultsModel::columnCount(const QModelIndex & /*parent*/) const { return 2; } diff --git a/plugins/References/CMakeLists.txt b/plugins/References/CMakeLists.txt index 083b53695..cd010759d 100644 --- a/plugins/References/CMakeLists.txt +++ b/plugins/References/CMakeLists.txt @@ -13,6 +13,6 @@ add_library(${PLUGIN_NAME} SHARED References.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/References/References.cpp b/plugins/References/References.cpp index d59ff27e5..576ec7b83 100644 --- a/plugins/References/References.cpp +++ b/plugins/References/References.cpp @@ -39,7 +39,11 @@ QMenu *References::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("Reference Searcher"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Reference Search"), QKeySequence(tr("Ctrl+R")), this, &References::showMenu); +#else menu_->addAction(tr("&Reference Search"), this, &References::showMenu, QKeySequence(tr("Ctrl+R"))); +#endif } return menu_; diff --git a/plugins/SymbolViewer/CMakeLists.txt b/plugins/SymbolViewer/CMakeLists.txt index 3e74ececf..2d90f47a4 100644 --- a/plugins/SymbolViewer/CMakeLists.txt +++ b/plugins/SymbolViewer/CMakeLists.txt @@ -13,6 +13,6 @@ add_library(${PLUGIN_NAME} SHARED SymbolViewer.h ) -target_link_libraries(${PLUGIN_NAME} Qt${QT_VERSION_MAJOR}::Widgets edb) +target_link_libraries(${PLUGIN_NAME} Qt::Widgets edb) build_plugin(${PLUGIN_NAME}) diff --git a/plugins/SymbolViewer/SymbolViewer.cpp b/plugins/SymbolViewer/SymbolViewer.cpp index bab7230bf..26bf8232c 100644 --- a/plugins/SymbolViewer/SymbolViewer.cpp +++ b/plugins/SymbolViewer/SymbolViewer.cpp @@ -39,7 +39,11 @@ QMenu *SymbolViewer::menu(QWidget *parent) { if (!menu_) { menu_ = new QMenu(tr("SymbolViewer"), parent); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + menu_->addAction(tr("&Symbol Viewer"), QKeySequence(tr("Ctrl+Alt+S")), this, &SymbolViewer::showMenu); +#else menu_->addAction(tr("&Symbol Viewer"), this, &SymbolViewer::showMenu, QKeySequence(tr("Ctrl+Alt+S"))); +#endif } return menu_; diff --git a/src/BinaryString.cpp b/src/BinaryString.cpp index d03fb097e..ea832b656 100644 --- a/src/BinaryString.cpp +++ b/src/BinaryString.cpp @@ -186,7 +186,7 @@ void BinaryString::on_txtHex_textEdited(const QString &text) { utf16Char = (utf16Char << 8) | ch; #endif - textAscii += ch; + textAscii += static_cast(ch); if (counter++ & 1) { textUTF16 += QChar(utf16Char); @@ -222,7 +222,7 @@ QByteArray BinaryString::value() const { */ void BinaryString::setValue(const QByteArray &data) { - valueOriginalLength_ = data.size(); + valueOriginalLength_ = static_cast(data.size()); on_keepSize_stateChanged(ui->keepSize->checkState()); const auto temp = QString::fromLatin1(data.data(), data.size()); diff --git a/src/ByteShiftArray.cpp b/src/ByteShiftArray.cpp index eda0a43b2..ce895d361 100644 --- a/src/ByteShiftArray.cpp +++ b/src/ByteShiftArray.cpp @@ -64,7 +64,7 @@ ByteShiftArray &ByteShiftArray::shr() { * @return The size of the array. */ int ByteShiftArray::size() const { - return data_.size(); + return static_cast(data_.size()); } /** diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d7fd1e86a..ab2cf9206 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,13 +5,15 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) -find_package(Qt5 REQUIRED Widgets Xml Svg LinguistTools) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED Widgets Xml Svg LinguistTools) -qt5_add_translation(QM_FILES + +qt_add_translation(QM_FILES # add translation files in /src/res/translations here res/translations/edb_zh_CN.ts ) + # Create translations QRC file - translations.qrc set(TRANSLATIONS_QRC "${CMAKE_CURRENT_BINARY_DIR}/translations.qrc") @@ -24,7 +26,7 @@ endforeach() file(APPEND ${TRANSLATIONS_QRC} "\n\t\n") list(APPEND QRC_FILES ${TRANSLATIONS_QRC}) -qt5_add_resources(QRC_SOURCES +qt_add_resources(QRC_SOURCES res/debugger.qrc res/themes.qrc res/breeze-edb.qrc @@ -284,9 +286,9 @@ target_compile_definitions(edb PRIVATE -DDEFAULT_PLUGIN_PATH="${DEFAULT_PLUGIN_D target_link_libraries(edb ${CAPSTONE_LIBRARIES} - Qt${QT_VERSION_MAJOR}::Widgets - Qt${QT_VERSION_MAJOR}::Xml - Qt${QT_VERSION_MAJOR}::Svg + Qt::Widgets + Qt::Xml + Qt::Svg QHexView ${DOUBLE_CONVERSION_LIBRARIES} ) diff --git a/src/Configuration.cpp b/src/Configuration.cpp index bbed101d1..992e1f70e 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include #define STRINGIFY(x) #x @@ -27,14 +29,16 @@ namespace { * @return The default plugin path. */ QString getDefaultPluginPath() { -#ifdef DEFAULT_PLUGIN_PATH +#if defined(DEFAULT_PLUGIN_PATH) const QString default_plugin_path = DEFAULT_PLUGIN_PATH; #else const QString edb_lib_dir = QCoreApplication::applicationDirPath() + (EDB_IS_64_BIT ? "/../lib64/edb" : "/../lib/edb"); const QString edb_binary_dir = QCoreApplication::applicationDirPath(); // If the binary is in its installation directory, then look for plugins in their installation directory // Otherwise assume that we are in build directory, so the plugins are in the same directory as the binary - const QString default_plugin_path = QRegExp(".*/bin/?$").exactMatch(edb_binary_dir) ? edb_lib_dir : edb_binary_dir; + static const QRegularExpression re("^.*/bin/?$"); + const QRegularExpressionMatch match = re.match(edb_binary_dir); + const QString default_plugin_path = match.hasMatch() ? edb_lib_dir : edb_binary_dir; #endif return default_plugin_path; } diff --git a/src/FloatX.cpp b/src/FloatX.cpp index 814685341..f5440bfeb 100644 --- a/src/FloatX.cpp +++ b/src/FloatX.cpp @@ -367,24 +367,29 @@ QValidator::State FloatXValidator::validate(QString &input, int &) const } // OK, so we failed to read it or it is unfinished. Let's check whether it's intermediate or invalid. - static const QRegExp basicFormat("[+-]?[0-9]*\\.?[0-9]*(e([+-]?[0-9]*)?)?"); - static const QRegExp specialFormat("[+-]?[sq]?nan|[+-]?inf", Qt::CaseInsensitive); - static const QRegExp hexfloatFormat("[+-]?0x[0-9a-f]*\\.?[0-9a-f]*(p([+-]?[0-9]*)?)?", Qt::CaseInsensitive); - static const QRegExp specialFormatUnfinished("[+-]?[sq]?(n(an?)?)?|[+-]?(i(nf?)?)?", Qt::CaseInsensitive); + static const QRegularExpression basicFormat("^[+-]?[0-9]*\\.?[0-9]*(e([+-]?[0-9]*)?)?$"); + static const QRegularExpression specialFormat("^[+-]?[sq]?nan|[+-]?inf$", QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression hexfloatFormat("^[+-]?0x[0-9a-f]*\\.?[0-9a-f]*(p([+-]?[0-9]*)?)?$", QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression specialFormatUnfinished("^[+-]?[sq]?(n(an?)?)?|[+-]?(i(nf?)?)?$", QRegularExpression::CaseInsensitiveOption); - if (hexfloatFormat.exactMatch(input)) { + const QRegularExpressionMatch match = basicFormat.match(input); + const QRegularExpressionMatch matchSpecial = specialFormat.match(input); + const QRegularExpressionMatch matchHex = hexfloatFormat.match(input); + const QRegularExpressionMatch matchSpecialUnfinished = specialFormatUnfinished.match(input); + + if (matchHex.hasMatch()) { return QValidator::Intermediate; } - if (basicFormat.exactMatch(input)) { + if (match.hasMatch()) { return QValidator::Intermediate; } - if (specialFormat.exactMatch(input)) { + if (matchSpecial.hasMatch()) { return QValidator::Acceptable; } - if (specialFormatUnfinished.exactMatch(input)) { + if (matchSpecialUnfinished.hasMatch()) { return QValidator::Intermediate; } diff --git a/src/HexStringValidator.cpp b/src/HexStringValidator.cpp index 577c0448d..54b06a1d2 100644 --- a/src/HexStringValidator.cpp +++ b/src/HexStringValidator.cpp @@ -51,8 +51,8 @@ QValidator::State HexStringValidator::validate(QString &input, int &pos) const { // (if any was deleted) was a space? and special case this? // as to not have the minor bug in this case? - const int char_pos = pos - input.leftRef(pos).count(' '); - int chars = 0; + const qsizetype char_pos = pos - input.left(pos).count(' '); + int chars = 0; fixup(input); pos = 0; diff --git a/src/MemoryRegions.cpp b/src/MemoryRegions.cpp index 84cbc3984..384a96aa1 100644 --- a/src/MemoryRegions.cpp +++ b/src/MemoryRegions.cpp @@ -131,16 +131,14 @@ QModelIndex MemoryRegions::parent(const QModelIndex &index) const { /** * @brief */ -int MemoryRegions::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return regions_.size(); +int MemoryRegions::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(regions_.size()); } /** * @brief */ -int MemoryRegions::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int MemoryRegions::columnCount(const QModelIndex & /*parent*/) const { return 4; } diff --git a/src/PluginModel.cpp b/src/PluginModel.cpp index 0c391d481..b9ff1f0cc 100644 --- a/src/PluginModel.cpp +++ b/src/PluginModel.cpp @@ -90,17 +90,15 @@ QVariant PluginModel::headerData(int section, Qt::Orientation orientation, int r /** * @brief */ -int PluginModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int PluginModel::columnCount(const QModelIndex & /*parent*/) const { return 4; } /** * @brief */ -int PluginModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return items_.size(); +int PluginModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(items_.size()); } /** diff --git a/src/ProcessModel.cpp b/src/ProcessModel.cpp index 932bcc696..b6bc05140 100644 --- a/src/ProcessModel.cpp +++ b/src/ProcessModel.cpp @@ -71,14 +71,24 @@ QVariant ProcessModel::headerData(int section, Qt::Orientation orientation, int return QVariant(); } -int ProcessModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +/** + * @brief Gets the number of columns in the model. + * + * @param parent The parent index. + * @return The number of columns in the model. + */ +int ProcessModel::columnCount(const QModelIndex & /*parent*/) const { return 3; } -int ProcessModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return items_.size(); +/** + * @brief Gets the number of rows in the model. + * + * @param parent The parent index. + * @return The number of rows in the model. + */ +int ProcessModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(items_.size()); } void ProcessModel::addProcess(const std::shared_ptr &process) { diff --git a/src/RecentFileManager.cpp b/src/RecentFileManager.cpp index 3ed8b39b4..d2744e0d7 100644 --- a/src/RecentFileManager.cpp +++ b/src/RecentFileManager.cpp @@ -157,7 +157,7 @@ RecentFileManager::RecentFile RecentFileManager::mostRecent() const { * @return The number of entries. */ int RecentFileManager::entryCount() const { - return files_.size(); + return static_cast(files_.size()); } /** diff --git a/src/RegisterViewModelBase.cpp b/src/RegisterViewModelBase.cpp index 27a8aa852..746ca2a02 100644 --- a/src/RegisterViewModelBase.cpp +++ b/src/RegisterViewModelBase.cpp @@ -421,11 +421,20 @@ bool Model::setData(const QModelIndex &index, const QVariant &data, int role) { case RawValueRole: if (this->data(index, IsNormalRegisterRole).toBool()) { auto reg = checked_cast(item); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (role == Qt::EditRole && data.typeId() == QMetaType::QString) { + ok = reg->setValue(data.toString()); + } else if (data.typeId() == QMetaType::QByteArray) { + ok = reg->setValue(data.toByteArray()); + } +#else if (role == Qt::EditRole && data.type() == QVariant::String) { ok = reg->setValue(data.toString()); } else if (data.type() == QVariant::ByteArray) { ok = reg->setValue(data.toByteArray()); } +#endif } break; case ValueAsRegisterRole: { diff --git a/src/Theme.cpp b/src/Theme.cpp index 32f8d857f..d2815df71 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -154,10 +154,17 @@ Theme readTheme(QSettings &settings, const Theme &baseTheme = Theme()) { * @return The system theme. */ Theme readSystemTheme() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (QApplication::palette().window().color().lightnessF() >= 0.5f) { + QSettings settings(":/themes/system-light.ini", QSettings::IniFormat); + return readTheme(settings); + } +#else if (QApplication::palette().window().color().lightnessF() >= 0.5) { QSettings settings(":/themes/system-light.ini", QSettings::IniFormat); return readTheme(settings); } +#endif QSettings settings(":/themes/system-dark.ini", QSettings::IniFormat); return readTheme(settings); diff --git a/src/ThreadsModel.cpp b/src/ThreadsModel.cpp index 04729496e..411b33883 100644 --- a/src/ThreadsModel.cpp +++ b/src/ThreadsModel.cpp @@ -93,14 +93,12 @@ QVariant ThreadsModel::headerData(int section, Qt::Orientation orientation, int return QVariant(); } -int ThreadsModel::columnCount(const QModelIndex &parent) const { - Q_UNUSED(parent) +int ThreadsModel::columnCount(const QModelIndex & /*parent*/) const { return 5; } -int ThreadsModel::rowCount(const QModelIndex &parent) const { - Q_UNUSED(parent) - return items_.size(); +int ThreadsModel::rowCount(const QModelIndex & /*parent*/) const { + return static_cast(items_.size()); } void ThreadsModel::addThread(const std::shared_ptr &thread, bool current) { diff --git a/src/arch/x86-generic/ArchProcessor.cpp b/src/arch/x86-generic/ArchProcessor.cpp index 8ab119937..730b1012a 100644 --- a/src/arch/x86-generic/ArchProcessor.cpp +++ b/src/arch/x86-generic/ArchProcessor.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -315,10 +316,10 @@ void resolve_function_parameters_helper(T parameter_registers, const State &stat // we will always be removing the last 2 chars '+0' from the string as well // as chopping the region prefix we like to prepend to symbols QString func_name; - const int colon_index = symname.indexOf(prefix); + const qsizetype colon_index = symname.indexOf(prefix); if (colon_index != -1) { - func_name = symname.left(symname.length() - 2).mid(colon_index + prefix.size()); + func_name = symname.left(symname.length() - 2).mid(static_cast(colon_index) + prefix.size()); } // safe not to check for -1, it means 'rest of string' for the mid function @@ -606,10 +607,10 @@ QString formatBCD(const edb::value80 &v) { auto hex = v.toHexString(); // Low bytes which contain 18 digits must be decimal. If not, return the raw hex value. - if (hex.mid(2).contains(QRegExp("[A-Fa-f]"))) { + if (hex.mid(2).contains(QRegularExpression("[A-Fa-f]"))) { return "0x" + hex; } - hex.replace(QRegExp("^..0*"), ""); + hex.replace(QRegularExpression("^..0*"), ""); return (v.negative() ? '-' + hex : hex) + " (BCD)"; } diff --git a/src/capstone-edb/Instruction.cpp b/src/capstone-edb/Instruction.cpp index 5fc6b9f2b..128c31022 100644 --- a/src/capstone-edb/Instruction.cpp +++ b/src/capstone-edb/Instruction.cpp @@ -6,7 +6,6 @@ #include "Instruction.h" -#include #include #include #include @@ -416,18 +415,18 @@ QString Formatter::adjustInstructionText(const Instruction &insn) const { operands.replace(" + ", "+"); operands.replace(" - ", "-"); - operands.replace(QRegExp("\\bxword "), "tbyte "); - operands.replace(QRegExp("(word|byte) ptr "), "\\1 "); + operands.replace(QRegularExpression("\\bxword "), "tbyte "); + operands.replace(QRegularExpression("(word|byte) ptr "), "\\1 "); #if defined(EDB_X86) || defined(EDB_X86_64) if (activeFormatter.options().simplifyRIPRelativeTargets && isX86_64() && (insn->detail->x86.modrm & 0xc7) == 0x05) { - QRegExp ripRel("\\brip ?[+-] ?((0x)?[0-9a-fA-F]+)\\b"); + QRegularExpression ripRel("\\brip ?[+-] ?((0x)?[0-9a-fA-F]+)\\b"); operands.replace(ripRel, "rel 0x" + QString::number(insn->detail->x86.disp + insn->address + insn->size, 16)); } if (insn.operandCount() == 2 && insn->id != X86_INS_MOVZX && insn->id != X86_INS_MOVSX && ((insn[0]->type == X86_OP_REG && insn[1]->type == X86_OP_MEM) || (insn[1]->type == X86_OP_REG && insn[0]->type == X86_OP_MEM))) { - operands.replace(QRegExp("(\\b.?(mm)?word|byte)\\b( ptr)? "), ""); + operands.replace(QRegularExpression("(\\b.?(mm)?word|byte)\\b( ptr)? "), ""); } #endif return operands; diff --git a/src/edb.cpp b/src/edb.cpp index 494d81df6..97036d478 100644 --- a/src/edb.cpp +++ b/src/edb.cpp @@ -668,7 +668,7 @@ bool get_ascii_string_at_address(address_t address, QString &s, int min_length, is_string = s.length() >= min_length; if (is_string) { - found_length = s.length(); + found_length = static_cast(s.length()); s.replace("\r", "\\r"); s.replace("\n", "\\n"); s.replace("\t", "\\t"); @@ -727,7 +727,7 @@ bool get_utf16_string_at_address(address_t address, QString &s, int min_length, is_string = s.length() >= min_length; if (is_string) { - found_length = s.length(); + found_length = static_cast(s.length()); s.replace("\r", "\\r"); s.replace("\n", "\\n"); s.replace("\t", "\\t"); diff --git a/src/graph/GraphNode.cpp b/src/graph/GraphNode.cpp index 9e7ccb809..7c308661f 100644 --- a/src/graph/GraphNode.cpp +++ b/src/graph/GraphNode.cpp @@ -199,7 +199,7 @@ void GraphNode::drawLabel(const QString &text) { break; } - line.setNumColumns(l.length()); + line.setNumColumns(static_cast(l.length())); line.setPosition(QPoint(0, y)); y += static_cast(fm.lineSpacing()); } diff --git a/src/main.cpp b/src/main.cpp index 57cbbed6e..4986f34ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -282,8 +282,10 @@ int main(int argc, char *argv[]) { QT_REQUIRE_VERSION(argc, argv, "5.9.0"); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif QApplication app(argc, argv); QApplication::setWindowIcon(QIcon(":/debugger/images/edb.svg")); @@ -296,9 +298,15 @@ int main(int argc, char *argv[]) { // load some translations QTranslator qtTranslator; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (qtTranslator.load(QLocale(), QLatin1String("qtbase"), QLatin1String("_"), QLibraryInfo::path(QLibraryInfo::TranslationsPath))) { + QApplication::installTranslator(&qtTranslator); + } +#else if (qtTranslator.load(QLocale(), QLatin1String("qtbase"), QLatin1String("_"), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { QApplication::installTranslator(&qtTranslator); } +#endif QTranslator translator; // look up e.g. :/translations/edb_{lang}.qm @@ -383,11 +391,19 @@ int main(int argc, char *argv[]) { QApplication::setPalette(themePalette()); // Light/Dark icons on all platforms +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (QApplication::palette().window().color().lightnessF() >= 0.5f) { + QIcon::setThemeName(QLatin1String("breeze-edb")); + } else { + QIcon::setThemeName(QLatin1String("breeze-dark-edb")); + } +#else if (QApplication::palette().window().color().lightnessF() >= 0.5) { QIcon::setThemeName(QLatin1String("breeze-edb")); } else { QIcon::setThemeName(QLatin1String("breeze-dark-edb")); } +#endif return start_debugger(launch_args); } diff --git a/src/qhexview b/src/qhexview index 4bd4ce071..339881dca 160000 --- a/src/qhexview +++ b/src/qhexview @@ -1 +1 @@ -Subproject commit 4bd4ce071d57719877bf20897604bb2ccbbd88da +Subproject commit 339881dca74bf1b95a27227fd56008cbab87bfbd diff --git a/src/widgets/NavigationHistory.cpp b/src/widgets/NavigationHistory.cpp index 2221ec32d..4a1104403 100644 --- a/src/widgets/NavigationHistory.cpp +++ b/src/widgets/NavigationHistory.cpp @@ -25,14 +25,14 @@ void NavigationHistory::add(edb::address_t address) { return; } - for (int i = list_.size() - 1; i >= pos_; i--) { + for (auto i = static_cast(list_.size()) - 1; i >= pos_; i--) { if (address == list_.at(i)) { return; } } } - pos_ = list_.size(); + pos_ = static_cast(list_.size()); list_.append(address); lastOp_ = LastOp::None; } diff --git a/src/widgets/QDisassemblyView.cpp b/src/widgets/QDisassemblyView.cpp index ce9c77840..0019e8575 100644 --- a/src/widgets/QDisassemblyView.cpp +++ b/src/widgets/QDisassemblyView.cpp @@ -181,7 +181,7 @@ void QDisassemblyView::keyPressEvent(QKeyEvent *event) { verticalScrollBar()->setValue(verticalScrollBar()->maximum()); } else if (event->matches(QKeySequence::MoveToNextLine)) { const edb::address_t selected = selectedAddress(); - const int idx = showAddresses_.indexOf(selected); + const auto idx = static_cast(showAddresses_.indexOf(selected)); if (selected != 0 && idx > 0 && idx < showAddresses_.size() - 1 - partialLastLine_) { setSelectedAddress(showAddresses_[idx + 1]); } else { @@ -199,7 +199,7 @@ void QDisassemblyView::keyPressEvent(QKeyEvent *event) { } } else if (event->matches(QKeySequence::MoveToPreviousLine)) { const edb::address_t selected = selectedAddress(); - const int idx = showAddresses_.indexOf(selected); + const auto idx = static_cast(showAddresses_.indexOf(selected)); if (selected != 0 && idx > 0) { // we already know the previous instruction setSelectedAddress(showAddresses_[idx - 1]); @@ -607,7 +607,8 @@ void QDisassemblyView::drawInstruction(QPainter &painter, const edb::Instruction const bool syntax_highlighting_enabled = edb::v1::config().syntax_highlighting_enabled && !selected; - QString opcode = instructionString(inst); + QString opcode = instructionString(inst); + auto opcode_length = static_cast(opcode.length()); if (is_filling) { if (syntax_highlighting_enabled) { @@ -619,7 +620,7 @@ void QDisassemblyView::drawInstruction(QPainter &painter, const edb::Instruction painter.drawText( x, y, - opcode.length() * fontWidth_, + opcode_length * fontWidth_, ctx->lineHeight, Qt::AlignVCenter, opcode); @@ -660,7 +661,7 @@ void QDisassemblyView::drawInstruction(QPainter &painter, const edb::Instruction textLayout.endLayout(); - map = new QPixmap(QSize(opcode.length() * fontWidth_, ctx->lineHeight) * devicePixelRatio()); + map = new QPixmap(QSize(opcode_length * fontWidth_, ctx->lineHeight) * devicePixelRatio()); map->setDevicePixelRatio(devicePixelRatio()); map->fill(Qt::transparent); QPainter cache_painter(map); @@ -673,7 +674,7 @@ void QDisassemblyView::drawInstruction(QPainter &painter, const edb::Instruction } painter.drawPixmap(x, y, *map); } else { - QRectF rectangle(x, y, opcode.length() * fontWidth_, ctx->lineHeight); + QRectF rectangle(x, y, opcode_length * fontWidth_, ctx->lineHeight); painter.drawText(rectangle, Qt::AlignVCenter, opcode); } } @@ -868,7 +869,9 @@ void QDisassemblyView::drawRegisterBadges(QPainter &painter, DrawingContext *ctx for (int line = 0; line < ctx->linesToRender; line++) { if (!badge_labels[line].isEmpty()) { - int width = badge_labels[line].length() * fontWidth_ + fontWidth_ / 2; + auto badge_length = static_cast(badge_labels[line].size()); + + int width = badge_length * fontWidth_ + fontWidth_ / 2; int height = ctx->lineHeight; int triangle_point = line1() - 3; int x = triangle_point - (height / 2) - width; @@ -894,7 +897,7 @@ void QDisassemblyView::drawRegisterBadges(QPainter &painter, DrawingContext *ctx painter.drawText( bounds.x() + fontWidth_ / 4, line * ctx->lineHeight, - fontWidth_ * badge_labels[line].size(), + fontWidth_ * badge_length, ctx->lineHeight, Qt::AlignVCenter, (edb::v1::config().uppercase_disassembly ? badge_labels[line].toUpper() : badge_labels[line])); @@ -1850,9 +1853,15 @@ edb::address_t QDisassemblyView::addressFromCoord(int x, int y) const { * @brief */ void QDisassemblyView::mouseDoubleClickEvent(QMouseEvent *event) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const int x = qRound(event->position().x()); +#else + const int x = event->x(); +#endif + if (region_) { if (event->button() == Qt::LeftButton) { - if (event->x() < line2()) { + if (x < line2()) { const edb::address_t address = addressFromPoint(event->pos()); if (region_->contains(address)) { @@ -1936,8 +1945,15 @@ void QDisassemblyView::updateSelectedAddress(QMouseEvent *event) { * @brief */ void QDisassemblyView::mousePressEvent(QMouseEvent *event) { - const int event_x = event->x() - line0(); + if (region_) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const int x = qRound(event->position().x()); +#else + const int x = event->x(); +#endif + const int event_x = x - line0(); + if (event->button() == Qt::LeftButton) { if (near_line(event_x, line1()) && edb::v1::config().show_jump_arrow) { movingLine1_ = true; @@ -1963,7 +1979,12 @@ void QDisassemblyView::mousePressEvent(QMouseEvent *event) { void QDisassemblyView::mouseMoveEvent(QMouseEvent *event) { if (region_) { - const int x_pos = event->x() - line0(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + const int x = qRound(event->position().x()); +#else + const int x = event->x(); +#endif + const int x_pos = x - line0(); if (movingLine1_) { if (line2_ == 0) { diff --git a/src/widgets/SyntaxHighlighter.cpp b/src/widgets/SyntaxHighlighter.cpp index 0f919afe2..bc3fae040 100644 --- a/src/widgets/SyntaxHighlighter.cpp +++ b/src/widgets/SyntaxHighlighter.cpp @@ -25,10 +25,7 @@ SyntaxHighlighter::SyntaxHighlighter(QObject *parent) * @param format The text format to apply. */ SyntaxHighlighter::HighlightingRule::HighlightingRule(const QString ®ex, const QTextCharFormat &fmt) - : pattern(regex) { - - pattern.setCaseSensitivity(Qt::CaseInsensitive); - format = fmt; + : pattern(regex, QRegularExpression::CaseInsensitiveOption), format(fmt) { } /** @@ -172,19 +169,23 @@ QVector SyntaxHighlighter::highlightBlock(const QStrin QVector ranges; for (const HighlightingRule &rule : rules_) { - int index = rule.pattern.indexIn(text); + + QRegularExpressionMatch match = rule.pattern.match(text); + + qsizetype index = match.capturedStart(); while (index >= 0) { - const int length = rule.pattern.matchedLength(); + const auto length = static_cast(match.capturedLength()); QTextLayout::FormatRange range; range.format = rule.format; - range.start = index; + range.start = static_cast(index); range.length = length; ranges.push_back(range); - index = rule.pattern.indexIn(text, index + length); + match = rule.pattern.match(text, static_cast(index) + length); + index = match.capturedStart(); } } diff --git a/src/widgets/SyntaxHighlighter.h b/src/widgets/SyntaxHighlighter.h index c726583be..bab388f83 100644 --- a/src/widgets/SyntaxHighlighter.h +++ b/src/widgets/SyntaxHighlighter.h @@ -7,7 +7,7 @@ #ifndef SYNTAX_HIGHLIGHTER_H_20191119_ #define SYNTAX_HIGHLIGHTER_H_20191119_ -#include +#include #include #include #include @@ -30,7 +30,7 @@ class SyntaxHighlighter : public QObject { HighlightingRule() = default; HighlightingRule(const QString ®ex, const QTextCharFormat &fmt); - QRegExp pattern; + QRegularExpression pattern; QTextCharFormat format; };