fix multiple minor issues (c-style casts, default branch, etc.)

This commit is contained in:
xiphon 2020-02-28 10:25:57 +00:00
parent b4a65c52cc
commit 9deca92e07
8 changed files with 16 additions and 13 deletions

View file

@ -49,13 +49,15 @@ namespace {
DaemonManager * DaemonManager::m_instance = nullptr; DaemonManager * DaemonManager::m_instance = nullptr;
QStringList DaemonManager::m_clArgs; QStringList DaemonManager::m_clArgs;
DaemonManager *DaemonManager::instance(const QStringList *args) DaemonManager *DaemonManager::instance(const QStringList *args/* = nullptr*/)
{ {
if (!m_instance) { if (!m_instance) {
m_instance = new DaemonManager; m_instance = new DaemonManager;
// store command line arguments for later use // store command line arguments for later use
if (args != nullptr)
{
m_clArgs = *args; m_clArgs = *args;
m_clArgs.removeFirst(); }
} }
return m_instance; return m_instance;

View file

@ -42,7 +42,7 @@ class DaemonManager : public QObject
public: 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 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); Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);

View file

@ -792,7 +792,7 @@ QString Wallet::signMessage(const QString &message, bool filename) const
file.close(); file.close();
return ""; return "";
} }
std::string signature = m_walletImpl->signMessage(std::string((const char*)data, size)); std::string signature = m_walletImpl->signMessage(std::string(reinterpret_cast<const char*>(data), size));
file.unmap(data); file.unmap(data);
file.close(); file.close();
return QString::fromStdString(signature); return QString::fromStdString(signature);
@ -828,7 +828,7 @@ bool Wallet::verifySignedMessage(const QString &message, const QString &address,
file.close(); file.close();
return false; 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<const char*>(data), size), address.toStdString(), signature.toStdString());
file.unmap(data); file.unmap(data);
file.close(); file.close();
return ret; return ret;

View file

@ -164,10 +164,10 @@ int main(int argc, char *argv[])
isOpenGL = false; isOpenGL = false;
// disable "QApplication: invalid style override passed" warning // 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 #ifdef Q_OS_LINUX
// force platform xcb // force platform xcb
if (isDesktop) putenv((char*)"QT_QPA_PLATFORM=xcb"); if (isDesktop) qputenv("QT_QPA_PLATFORM", "xcb");
#endif #endif
// enable High DPI scaling // enable High DPI scaling
@ -393,8 +393,7 @@ int main(int argc, char *argv[])
// Exclude daemon manager from IOS // Exclude daemon manager from IOS
#ifndef Q_OS_IOS #ifndef Q_OS_IOS
const QStringList arguments = (QStringList) QCoreApplication::arguments().at(0); DaemonManager * daemonManager = DaemonManager::instance();
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
engine.rootContext()->setContextProperty("daemonManager", daemonManager); engine.rootContext()->setContextProperty("daemonManager", daemonManager);
#endif #endif

View file

@ -71,6 +71,8 @@ QVariant AddressBookModel::data(const QModelIndex &index, int role) const
// Qt doesnt support size_t overload type casting // Qt doesnt support size_t overload type casting
result.setValue(row.getRowId()); result.setValue(row.getRowId());
break; break;
default:
qCritical() << "Unimplemented role " << role;
} }
}); });
if (!found) { if (!found) {

View file

@ -53,7 +53,7 @@ int SubaddressAccountModel::rowCount(const QModelIndex &) const
QVariant SubaddressAccountModel::data(const QModelIndex &index, int role) 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<quint64>(index.row()) >= m_subaddressAccount->count())
return {}; return {};
QVariant result; QVariant result;

View file

@ -54,7 +54,7 @@ int SubaddressModel::rowCount(const QModelIndex &) const
QVariant SubaddressModel::data(const QModelIndex &index, int role) 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<quint64>(index.row()) >= m_subaddress->count())
return {}; return {};
QVariant result; QVariant result;

View file

@ -157,7 +157,7 @@ QVariant WalletKeysFilesModel::data(const QModelIndex & index, int role) const {
else if (role == PathRole) else if (role == PathRole)
return walletKeyFile.path(); return walletKeyFile.path();
else if (role == NetworkTypeRole) else if (role == NetworkTypeRole)
return walletKeyFile.networkType(); return static_cast<uint>(walletKeyFile.networkType());
else if (role == AddressRole) else if (role == AddressRole)
return walletKeyFile.address(); return walletKeyFile.address();
return QVariant(); return QVariant();