From 9deca92e0776a97e6364b6e6f36cc8a8718ea2cb Mon Sep 17 00:00:00 2001 From: xiphon Date: Fri, 28 Feb 2020 10:25:57 +0000 Subject: [PATCH] fix multiple minor issues (c-style casts, default branch, etc.) --- src/daemon/DaemonManager.cpp | 8 +++++--- src/daemon/DaemonManager.h | 2 +- src/libwalletqt/Wallet.cpp | 4 ++-- src/main/main.cpp | 7 +++---- src/model/AddressBookModel.cpp | 2 ++ src/model/SubaddressAccountModel.cpp | 2 +- src/model/SubaddressModel.cpp | 2 +- src/qt/KeysFiles.cpp | 2 +- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp index 215cd0a2..74f1077a 100644 --- a/src/daemon/DaemonManager.cpp +++ b/src/daemon/DaemonManager.cpp @@ -49,13 +49,15 @@ namespace { DaemonManager * DaemonManager::m_instance = nullptr; QStringList DaemonManager::m_clArgs; -DaemonManager *DaemonManager::instance(const QStringList *args) +DaemonManager *DaemonManager::instance(const QStringList *args/* = nullptr*/) { if (!m_instance) { m_instance = new DaemonManager; // store command line arguments for later use - m_clArgs = *args; - m_clArgs.removeFirst(); + if (args != nullptr) + { + m_clArgs = *args; + } } return m_instance; diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h index 774aecb3..e670373c 100644 --- a/src/daemon/DaemonManager.h +++ b/src/daemon/DaemonManager.h @@ -42,7 +42,7 @@ class DaemonManager : public QObject public: - static DaemonManager * instance(const QStringList *args); + static DaemonManager * instance(const QStringList *args = nullptr); Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false); Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback); diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 4b37b3b8..69035a90 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -792,7 +792,7 @@ QString Wallet::signMessage(const QString &message, bool filename) const file.close(); return ""; } - std::string signature = m_walletImpl->signMessage(std::string((const char*)data, size)); + std::string signature = m_walletImpl->signMessage(std::string(reinterpret_cast(data), size)); file.unmap(data); file.close(); return QString::fromStdString(signature); @@ -828,7 +828,7 @@ bool Wallet::verifySignedMessage(const QString &message, const QString &address, file.close(); return false; } - bool ret = m_walletImpl->verifySignedMessage(std::string((const char*)data, size), address.toStdString(), signature.toStdString()); + bool ret = m_walletImpl->verifySignedMessage(std::string(reinterpret_cast(data), size), address.toStdString(), signature.toStdString()); file.unmap(data); file.close(); return ret; diff --git a/src/main/main.cpp b/src/main/main.cpp index 9606ad7a..7a454140 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -164,10 +164,10 @@ int main(int argc, char *argv[]) isOpenGL = false; // disable "QApplication: invalid style override passed" warning - if (isDesktop) putenv((char*)"QT_STYLE_OVERRIDE=fusion"); + if (isDesktop) qputenv("QT_STYLE_OVERRIDE", "fusion"); #ifdef Q_OS_LINUX // force platform xcb - if (isDesktop) putenv((char*)"QT_QPA_PLATFORM=xcb"); + if (isDesktop) qputenv("QT_QPA_PLATFORM", "xcb"); #endif // enable High DPI scaling @@ -393,8 +393,7 @@ int main(int argc, char *argv[]) // Exclude daemon manager from IOS #ifndef Q_OS_IOS - const QStringList arguments = (QStringList) QCoreApplication::arguments().at(0); - DaemonManager * daemonManager = DaemonManager::instance(&arguments); + DaemonManager * daemonManager = DaemonManager::instance(); engine.rootContext()->setContextProperty("daemonManager", daemonManager); #endif diff --git a/src/model/AddressBookModel.cpp b/src/model/AddressBookModel.cpp index 98145bd1..d9086c34 100644 --- a/src/model/AddressBookModel.cpp +++ b/src/model/AddressBookModel.cpp @@ -71,6 +71,8 @@ QVariant AddressBookModel::data(const QModelIndex &index, int role) const // Qt doesnt support size_t overload type casting result.setValue(row.getRowId()); break; + default: + qCritical() << "Unimplemented role " << role; } }); if (!found) { diff --git a/src/model/SubaddressAccountModel.cpp b/src/model/SubaddressAccountModel.cpp index 51721b8b..e4bce411 100644 --- a/src/model/SubaddressAccountModel.cpp +++ b/src/model/SubaddressAccountModel.cpp @@ -53,7 +53,7 @@ int SubaddressAccountModel::rowCount(const QModelIndex &) const QVariant SubaddressAccountModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 || (unsigned)index.row() >= m_subaddressAccount->count()) + if (!index.isValid() || index.row() < 0 || static_cast(index.row()) >= m_subaddressAccount->count()) return {}; QVariant result; diff --git a/src/model/SubaddressModel.cpp b/src/model/SubaddressModel.cpp index 38168ecf..7d4c408c 100644 --- a/src/model/SubaddressModel.cpp +++ b/src/model/SubaddressModel.cpp @@ -54,7 +54,7 @@ int SubaddressModel::rowCount(const QModelIndex &) const QVariant SubaddressModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 || (unsigned)index.row() >= m_subaddress->count()) + if (!index.isValid() || index.row() < 0 || static_cast(index.row()) >= m_subaddress->count()) return {}; QVariant result; diff --git a/src/qt/KeysFiles.cpp b/src/qt/KeysFiles.cpp index 0d633439..e3d8810a 100644 --- a/src/qt/KeysFiles.cpp +++ b/src/qt/KeysFiles.cpp @@ -157,7 +157,7 @@ QVariant WalletKeysFilesModel::data(const QModelIndex & index, int role) const { else if (role == PathRole) return walletKeyFile.path(); else if (role == NetworkTypeRole) - return walletKeyFile.networkType(); + return static_cast(walletKeyFile.networkType()); else if (role == AddressRole) return walletKeyFile.address(); return QVariant();