From 01e38d12ede3109687208c387b50ee6a07c3426c Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 25 Dec 2020 00:08:06 +0000 Subject: [PATCH 1/3] Fix some compiler warnings --- CMakeLists.txt | 1 + src/AvatarProvider.cpp | 2 +- src/BlurhashProvider.cpp | 2 +- src/Cache.cpp | 24 ++++++++++++------------ src/CacheStructs.h | 2 +- src/ChatPage.cpp | 2 +- src/CommunitiesList.cpp | 4 ++-- src/CommunitiesListItem.cpp | 4 ++-- src/LoginPage.cpp | 4 ++-- src/MainWindow.cpp | 4 ++-- src/MxcImageProvider.cpp | 4 ++-- src/UsersModel.h | 2 +- src/Utils.cpp | 22 +++++++++++----------- src/dialogs/RoomSettings.cpp | 2 +- src/popups/SuggestionsPopup.cpp | 10 +++++----- src/timeline/EventStore.h | 6 +++--- src/timeline/TimelineModel.cpp | 6 +++--- 17 files changed, 51 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 326e5794..dbb3209a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -579,6 +579,7 @@ endif() if(WIN32) add_executable (nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS}) + target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601) else() add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS}) endif() diff --git a/src/AvatarProvider.cpp b/src/AvatarProvider.cpp index b1751c33..4c3969be 100644 --- a/src/AvatarProvider.cpp +++ b/src/AvatarProvider.cpp @@ -81,7 +81,7 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca cache::saveImage(cacheKey.toStdString(), res); } - emit proxy->avatarDownloaded(QByteArray(res.data(), res.size())); + emit proxy->avatarDownloaded(QByteArray(res.data(), (int)res.size())); }); } diff --git a/src/BlurhashProvider.cpp b/src/BlurhashProvider.cpp index 08dc2d40..cc7d5a73 100644 --- a/src/BlurhashProvider.cpp +++ b/src/BlurhashProvider.cpp @@ -31,7 +31,7 @@ BlurhashResponse::run() return; } - QImage image(decoded.image.data(), decoded.width, decoded.height, QImage::Format_RGB32); + QImage image(decoded.image.data(), (int)decoded.width, (int)decoded.height, QImage::Format_RGB32); m_image = image.copy(); emit finished(); diff --git a/src/Cache.cpp b/src/Cache.cpp index 674b5793..3099b0c9 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -675,7 +675,7 @@ Cache::image(lmdb::txn &txn, const std::string &url) const if (!res) return QByteArray(); - return QByteArray(image.data(), image.size()); + return QByteArray(image.data(), (int)image.size()); } catch (const lmdb::error &e) { nhlog::db()->critical("image: {}, {}", e.what(), url); } @@ -703,7 +703,7 @@ Cache::image(const QString &url) const if (!res) return QByteArray(); - return QByteArray(image.data(), image.size()); + return QByteArray(image.data(), (int)image.size()); } catch (const lmdb::error &e) { nhlog::db()->critical("image: {} {}", e.what(), url.toStdString()); } @@ -1257,9 +1257,9 @@ Cache::saveState(const mtx::responses::Sync &res) updatedInfo.tags = tmp.tags; } catch (const json::exception &e) { nhlog::db()->warn( - "failed to parse room info: room_id ({}), {}", + "failed to parse room info: room_id ({}), {}: {}", room.first, - std::string(data.data(), data.size())); + std::string(data.data(), data.size()), e.what()); } } } @@ -1458,9 +1458,9 @@ Cache::singleRoomInfo(const std::string &room_id) return tmp; } catch (const json::exception &e) { - nhlog::db()->warn("failed to parse room info: room_id ({}), {}", + nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}", room_id, - std::string(data.data(), data.size())); + std::string(data.data(), data.size()), e.what()); } } @@ -1492,9 +1492,9 @@ Cache::getRoomInfo(const std::vector &rooms) room_info.emplace(QString::fromStdString(room), std::move(tmp)); } catch (const json::exception &e) { - nhlog::db()->warn("failed to parse room info: room_id ({}), {}", + nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}", room, - std::string(data.data(), data.size())); + std::string(data.data(), data.size()), e.what()); } } else { // Check if the room is an invite. @@ -1508,9 +1508,9 @@ Cache::getRoomInfo(const std::vector &rooms) std::move(tmp)); } catch (const json::exception &e) { nhlog::db()->warn( - "failed to parse room info for invite: room_id ({}), {}", + "failed to parse room info for invite: room_id ({}), {}: {}", room, - std::string(data.data(), data.size())); + std::string(data.data(), data.size()), e.what()); } } } @@ -2044,7 +2044,7 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) } auto cursor = lmdb::cursor::open(txn, membersdb); - const int total = membersdb.size(txn); + const auto total = membersdb.size(txn); std::size_t ii = 0; std::string user_id; @@ -2327,7 +2327,7 @@ Cache::getRoomAvatar(const std::string &room_id) txn.commit(); - return QImage::fromData(QByteArray(response.data(), response.size())); + return QImage::fromData(QByteArray(response.data(), (int)response.size())); } std::vector diff --git a/src/CacheStructs.h b/src/CacheStructs.h index b3d9acf1..10f8cc54 100644 --- a/src/CacheStructs.h +++ b/src/CacheStructs.h @@ -61,7 +61,7 @@ struct RoomInfo //! Whether or not the room is an invite. bool is_invite = false; //! Total number of members in the room. - int16_t member_count = 0; + size_t member_count = 0; //! Who can access to the room. mtx::events::state::JoinRule join_rule = mtx::events::state::JoinRule::Public; bool guest_access = false; diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index e3325c05..37248022 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -439,7 +439,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token) try { http::client()->set_user(parse(userid.toStdString())); - } catch (const std::invalid_argument &e) { + } catch (const std::invalid_argument &) { nhlog::ui()->critical("bootstrapped with invalid user_id: {}", userid.toStdString()); } diff --git a/src/CommunitiesList.cpp b/src/CommunitiesList.cpp index 9af2ea9b..010200c8 100644 --- a/src/CommunitiesList.cpp +++ b/src/CommunitiesList.cpp @@ -104,7 +104,7 @@ CommunitiesList::setTagsForRoom(const QString &room_id, const std::vectorfirst.right(it->first.size() - strlen("tag:")).toStdString(); + it->first.right(static_cast(it->first.size() - strlen("tag:"))).toStdString(); if (std::find(tags.begin(), tags.end(), current_tag) != tags.end()) { // the room has this tag it->second->addRoom(room_id); @@ -246,7 +246,7 @@ CommunitiesList::fetchCommunityAvatar(const QString &id, const QString &avatarUr cache::saveImage(opts.mxc_url, res); - auto data = QByteArray(res.data(), res.size()); + auto data = QByteArray(res.data(), (int)res.size()); QPixmap pix; pix.loadFromData(data); diff --git a/src/CommunitiesListItem.cpp b/src/CommunitiesListItem.cpp index c56c74a2..dca91441 100644 --- a/src/CommunitiesListItem.cpp +++ b/src/CommunitiesListItem.cpp @@ -117,7 +117,7 @@ CommunitiesListItem::resolveName() const if (!name_.isEmpty()) return name_; if (groupId_.startsWith("tag:")) - return groupId_.right(groupId_.size() - strlen("tag:")); + return groupId_.right(static_cast(groupId_.size() - strlen("tag:"))); if (!groupId_.startsWith("+")) return QString("Group"); // Group with no name or id. @@ -132,7 +132,7 @@ CommunitiesListItem::updateTooltip() if (groupId_ == "world") setToolTip(tr("All rooms")); else if (is_tag()) { - QString tag = groupId_.right(groupId_.size() - strlen("tag:")); + QString tag = groupId_.right(static_cast(groupId_.size() - strlen("tag:"))); if (tag == "m.favourite") setToolTip(tr("Favourite rooms")); else if (tag == "m.lowpriority") diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp index 8076d6d6..05741cca 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp @@ -225,7 +225,7 @@ LoginPage::onMatrixIdEntered() try { user = parse(matrixid_input_->text().toStdString()); - } catch (const std::exception &e) { + } catch (const std::exception &) { showError(error_matrixid_label_, "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; @@ -389,7 +389,7 @@ LoginPage::onLoginButtonClicked() try { user = parse(matrixid_input_->text().toStdString()); - } catch (const std::exception &e) { + } catch (const std::exception &) { showError(error_matrixid_label_, "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d056aca6..570c0ab5 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -167,7 +167,7 @@ MainWindow::MainWindow(const QString profile, QWidget *parent) try { using namespace mtx::identifiers; http::client()->set_user(parse(user_id.toStdString())); - } catch (const std::invalid_argument &e) { + } catch (const std::invalid_argument &) { nhlog::ui()->critical("bootstrapped with invalid user_id: {}", user_id.toStdString()); } @@ -472,7 +472,7 @@ MainWindow::openReadReceiptsDialog(const QString &event_id) try { dialog->addUsers(cache::readReceipts(event_id, room_id)); - } catch (const lmdb::error &e) { + } catch (const lmdb::error &) { nhlog::db()->warn("failed to retrieve read receipts for {} {}", event_id.toStdString(), chat_page_->currentRoom().toStdString()); diff --git a/src/MxcImageProvider.cpp b/src/MxcImageProvider.cpp index d6564277..b48fe011 100644 --- a/src/MxcImageProvider.cpp +++ b/src/MxcImageProvider.cpp @@ -48,7 +48,7 @@ MxcImageResponse::run() return; } - auto data = QByteArray(res.data(), res.size()); + auto data = QByteArray(res.data(), (int)res.size()); cache::saveImage(fileName, data); m_image = utils::readImage(&data); if (!m_image.isNull()) { @@ -92,7 +92,7 @@ MxcImageResponse::run() temp = mtx::crypto::to_string( mtx::crypto::decrypt_file(temp, m_encryptionInfo.value())); - auto data = QByteArray(temp.data(), temp.size()); + auto data = QByteArray(temp.data(), (int)temp.size()); cache::saveImage(m_id, data); m_image = utils::readImage(&data); m_image.setText("original filename", diff --git a/src/UsersModel.h b/src/UsersModel.h index c60b34b8..cd9b780c 100644 --- a/src/UsersModel.h +++ b/src/UsersModel.h @@ -17,7 +17,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override { (void)parent; - return roomMembers_.size(); + return (int)roomMembers_.size(); } QVariant data(const QModelIndex &index, int role) const override; diff --git a/src/Utils.cpp b/src/Utils.cpp index 1d8fcd9c..7228faf4 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -244,20 +244,20 @@ utils::humanReadableFileSize(uint64_t bytes) int utils::levenshtein_distance(const std::string &s1, const std::string &s2) { - const int nlen = s1.size(); - const int hlen = s2.size(); + const auto nlen = s1.size(); + const auto hlen = s2.size(); if (hlen == 0) return -1; if (nlen == 1) - return s2.find(s1); + return (int)s2.find(s1); std::vector row1(hlen + 1, 0); - for (int i = 0; i < nlen; ++i) { - std::vector row2(1, i + 1); + for (size_t i = 0; i < nlen; ++i) { + std::vector row2(1, (int)i + 1); - for (int j = 0; j < hlen; ++j) { + for (size_t j = 0; j < hlen; ++j) { const int cost = s1[i] != s2[j]; row2.push_back( std::min(row1[j + 1] + 1, std::min(row2[j] + 1, row1[j] + cost))); @@ -381,15 +381,15 @@ utils::escapeBlacklistedHtml(const QString &rawStr) "caption", "/caption", "pre", "/pre", "span", "/span", "img", "/img"}; QByteArray data = rawStr.toUtf8(); QByteArray buffer; - const size_t length = data.size(); + const int length = data.size(); buffer.reserve(length); bool escapingTag = false; - for (size_t pos = 0; pos != length; ++pos) { + for (int pos = 0; pos != length; ++pos) { switch (data.at(pos)) { case '<': { bool oneTagMatched = false; - size_t endPos = std::min(static_cast(data.indexOf('>', pos)), - static_cast(data.indexOf(' ', pos))); + const int endPos = static_cast(std::min(static_cast(data.indexOf('>', pos)), + static_cast(data.indexOf(' ', pos)))); auto mid = data.mid(pos + 1, endPos - pos - 1); for (const auto &tag : allowedTags) { @@ -543,7 +543,7 @@ utils::generateContrastingHexColor(const QString &input, const QString &backgrou // Create a color for the input auto hash = hashQString(input); // create a hue value based on the hash of the input. - auto userHue = static_cast(qAbs(hash % 360)); + auto userHue = static_cast(hash % 360); // start with moderate saturation and lightness values. auto sat = 220; auto lightness = 125; diff --git a/src/dialogs/RoomSettings.cpp b/src/dialogs/RoomSettings.cpp index e6c9c58c..bd3cc26f 100644 --- a/src/dialogs/RoomSettings.cpp +++ b/src/dialogs/RoomSettings.cpp @@ -493,7 +493,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent) roomNameLabel_ = new QLabel(QString::fromStdString(info_.name), this); roomNameLabel_->setFont(largeFont); - auto membersLabel = new QLabel(tr("%n member(s)", "", info_.member_count), this); + auto membersLabel = new QLabel(tr("%n member(s)", "", (int)info_.member_count), this); auto textLayout = new QVBoxLayout; textLayout->addWidget(roomNameLabel_); diff --git a/src/popups/SuggestionsPopup.cpp b/src/popups/SuggestionsPopup.cpp index 2650b5e6..42efe6ce 100644 --- a/src/popups/SuggestionsPopup.cpp +++ b/src/popups/SuggestionsPopup.cpp @@ -35,14 +35,14 @@ SuggestionsPopup::addRooms(const std::vector &rooms) return; } - const size_t layoutCount = layout_->count(); - const size_t roomCount = rooms.size(); + const int layoutCount = (int)layout_->count(); + const int roomCount = (int)rooms.size(); // Remove the extra widgets from the layout. if (roomCount < layoutCount) removeLayoutItemsAfter(roomCount - 1); - for (size_t i = 0; i < roomCount; ++i) { + for (int i = 0; i < roomCount; ++i) { auto item = layout_->itemAt(i); // Create a new widget if there isn't already one in that @@ -62,7 +62,7 @@ SuggestionsPopup::addRooms(const std::vector &rooms) resetSelection(); adjustSize(); - resize(geometry().width(), 40 * rooms.size()); + resize(geometry().width(), 40 * (int)rooms.size()); selectNextSuggestion(); } @@ -150,7 +150,7 @@ SuggestionsPopup::removeLayoutItemsAfter(size_t startingPos) size_t posToRemove = layout_->count() - 1; QLayoutItem *item; - while (startingPos <= posToRemove && (item = layout_->takeAt(posToRemove)) != nullptr) { + while (startingPos <= posToRemove && (item = layout_->takeAt((int)posToRemove)) != nullptr) { delete item->widget(); delete item; diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index 2d5fb1be..a71e95d5 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -29,7 +29,7 @@ public: friend uint qHash(const Index &i, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; - seed = hash(seed, QByteArray::fromRawData(i.room.data(), i.room.size())); + seed = hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); seed = hash(seed, i.idx); return seed; } @@ -46,8 +46,8 @@ public: friend uint qHash(const IdIndex &i, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; - seed = hash(seed, QByteArray::fromRawData(i.room.data(), i.room.size())); - seed = hash(seed, QByteArray::fromRawData(i.id.data(), i.id.size())); + seed = hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); + seed = hash(seed, QByteArray::fromRawData(i.id.data(), (int)i.id.size())); return seed; } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 11fa60c0..adef886d 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -28,7 +28,7 @@ namespace std { inline uint qHash(const std::string &key, uint seed = 0) { - return qHash(QByteArray::fromRawData(key.data(), key.length()), seed); + return qHash(QByteArray::fromRawData(key.data(), (int)key.length()), seed); } } @@ -1208,7 +1208,7 @@ TimelineModel::cacheMedia(QString eventId) if (!file.open(QIODevice::WriteOnly)) return; - file.write(QByteArray(temp.data(), temp.size())); + file.write(QByteArray(temp.data(), (int)temp.size())); file.close(); } catch (const std::exception &e) { nhlog::ui()->warn("Error while saving file to: {}", e.what()); @@ -1227,7 +1227,7 @@ TimelineModel::formatTypingUsers(const std::vector &users, QColor bg) "multiple users. Second argument is the last user of that list. (If only one user is " "typing, %1 is empty. You should still use it in your string though to silence Qt " "warnings.)", - users.size()); + (int)users.size()); if (users.empty()) { return ""; From be9df45af90d68b1c1a15df3d0b34818bba3dbde Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 25 Dec 2020 04:11:24 +0100 Subject: [PATCH 2/3] Use vs2019 for CI --- CMakeLists.txt | 4 +- CMakeSettings.json | 112 ++++++++++++++++++++++++++------------------- appveyor.yml | 12 ++--- 3 files changed, 74 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb3209a..230d1ee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default") option(HUNTER_ENABLED "Enable Hunter package manager" OFF) include("cmake/HunterGate.cmake") HunterGate( - URL "https://github.com/cpp-pm/hunter/archive/v0.23.260.tar.gz" - SHA1 "13775235910a3fa85644568d1c5be8271de72e1c" + URL "https://github.com/cpp-pm/hunter/archive/v0.23.288.tar.gz" + SHA1 "6c9b2bc606d86ae31f96a62fc68f0a593024815b" ) option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED}) diff --git a/CMakeSettings.json b/CMakeSettings.json index cd32e378..310be648 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,46 +1,66 @@ -{ - "configurations": [ - { - "name": "Debug", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Debug", - "buildRoot": "${workspaceRoot}\\build-vc\\${name}", - "cmakeCommandArgs": "", - "variables": [ - { - "name": "CMAKE_TOOLCHAIN_FILE", - "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here - }, - { - "name": "CMAKE_INSTALL_PREFIX", - "value": "${workspaceRoot}/.deps" - }, - { - "name": "Qt5_DIR", - "value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here - } - ] - }, - { - "name": "Release", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Release", - "buildRoot": "${workspaceRoot}\\build-vc\\${name}", - "cmakeCommandArgs": "", - "variables": [ - { - "name": "CMAKE_TOOLCHAIN_FILE", - "value": "${workspaceRoot}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" // <-- change vcpkg location here - }, - { - "name": "CMAKE_INSTALL_PREFIX", - "value": "${workspaceRoot}/.deps" - }, - { - "name": "Qt5_DIR", - "value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here - } - ] - }, - ] -} +{ + "configurations": [ + { + "name": "Debug", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Debug", + "buildRoot": "${workspaceRoot}\\build-vc\\${name}", + "cmakeCommandArgs": "", + "variables": [ + { + "name": "HUNTER_ENABLED", + "value": "OFF", + "type": "BOOL" + }, + { + "name": "BUILD_SHARED_LIBS", + "value": "ON", + "type": "BOOL" + }, + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "${workspaceRoot}/.deps", + "type": "STRING" + }, + { + "name": "Qt5_DIR", + "value": "C:\\Qt\\5.12.5\\msvc2017_64\\lib\\cmake\\Qt5", // <-- change qt location here + "type": "STRING" + } + ], + "cmakeToolchain": "${workspaceRoot}\\toolchain.cmake", + "inheritEnvironments": [ "msvc_x64" ] + }, + { + "name": "Release", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Release", + "buildRoot": "${workspaceRoot}\\build-vc\\${name}", + "cmakeCommandArgs": "", + "variables": [ + { + "name": "HUNTER_ENABLED", + "value": "ON", + "type": "BOOL" + }, + { + "name": "BUILD_SHARED_LIBS", + "value": "OFF", + "type": "BOOL" + }, + { + "name": "CMAKE_INSTALL_PREFIX", + "value": "${workspaceRoot}/.deps", + "type": "STRING" + }, + { + "name": "Qt5_DIR", + "value": "C:\\Qt\\5.12.5\\msvc2017_64\\lib\\cmake\\Qt5", // <-- change qt location here + "type": "STRING" + } + ], + "cmakeToolchain": "${workspaceRoot}\\toolchain.cmake", + "inheritEnvironments": [ "msvc_x64" ] + } + ] +} \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 16fea8d7..6f50bf4a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ version: 0.7.2-{build} configuration: Release -image: Visual Studio 2017 +image: Visual Studio 2019 platform: x64 environment: @@ -22,9 +22,9 @@ build: verbosity: minimal install: - - set QT_DIR=C:\Qt\5.13\msvc2017_64 - - set PATH=%PATH%;%QT_DIR%\bin - - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" + - set QT_DIR=C:\Qt\5.15\msvc2019_64 + - set PATH=C:\Strawberry\perl\bin;%PATH%;%QT_DIR%\bin + - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 build_script: # VERSION format: branch-master/branch-1.2 @@ -46,8 +46,8 @@ build_script: - echo %DATE% # Build nheko - #- cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild - - cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild + #- cmake -G "Visual Studio 15 2017 Win64" -H. -Bbuild + - cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild -DHUNTER_ROOT="C:\hunter" -DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release From 904cafcd392c498f6f2ee2e7da061b98524857bc Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 25 Dec 2020 04:11:47 +0100 Subject: [PATCH 3/3] lint --- src/BlurhashProvider.cpp | 3 ++- src/Cache.cpp | 20 ++++++++++++-------- src/CommunitiesList.cpp | 3 ++- src/Utils.cpp | 5 +++-- src/popups/SuggestionsPopup.cpp | 3 ++- src/timeline/EventStore.h | 6 ++++-- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/BlurhashProvider.cpp b/src/BlurhashProvider.cpp index cc7d5a73..acaef400 100644 --- a/src/BlurhashProvider.cpp +++ b/src/BlurhashProvider.cpp @@ -31,7 +31,8 @@ BlurhashResponse::run() return; } - QImage image(decoded.image.data(), (int)decoded.width, (int)decoded.height, QImage::Format_RGB32); + QImage image( + decoded.image.data(), (int)decoded.width, (int)decoded.height, QImage::Format_RGB32); m_image = image.copy(); emit finished(); diff --git a/src/Cache.cpp b/src/Cache.cpp index 3099b0c9..3f8d5d96 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -1259,7 +1259,8 @@ Cache::saveState(const mtx::responses::Sync &res) nhlog::db()->warn( "failed to parse room info: room_id ({}), {}: {}", room.first, - std::string(data.data(), data.size()), e.what()); + std::string(data.data(), data.size()), + e.what()); } } } @@ -1460,7 +1461,8 @@ Cache::singleRoomInfo(const std::string &room_id) } catch (const json::exception &e) { nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}", room_id, - std::string(data.data(), data.size()), e.what()); + std::string(data.data(), data.size()), + e.what()); } } @@ -1494,7 +1496,8 @@ Cache::getRoomInfo(const std::vector &rooms) } catch (const json::exception &e) { nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}", room, - std::string(data.data(), data.size()), e.what()); + std::string(data.data(), data.size()), + e.what()); } } else { // Check if the room is an invite. @@ -1507,10 +1510,11 @@ Cache::getRoomInfo(const std::vector &rooms) room_info.emplace(QString::fromStdString(room), std::move(tmp)); } catch (const json::exception &e) { - nhlog::db()->warn( - "failed to parse room info for invite: room_id ({}), {}: {}", - room, - std::string(data.data(), data.size()), e.what()); + nhlog::db()->warn("failed to parse room info for invite: " + "room_id ({}), {}: {}", + room, + std::string(data.data(), data.size()), + e.what()); } } } @@ -2043,7 +2047,7 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) } } - auto cursor = lmdb::cursor::open(txn, membersdb); + auto cursor = lmdb::cursor::open(txn, membersdb); const auto total = membersdb.size(txn); std::size_t ii = 0; diff --git a/src/CommunitiesList.cpp b/src/CommunitiesList.cpp index 010200c8..f3af9932 100644 --- a/src/CommunitiesList.cpp +++ b/src/CommunitiesList.cpp @@ -104,7 +104,8 @@ CommunitiesList::setTagsForRoom(const QString &room_id, const std::vectorfirst.right(static_cast(it->first.size() - strlen("tag:"))).toStdString(); + it->first.right(static_cast(it->first.size() - strlen("tag:"))) + .toStdString(); if (std::find(tags.begin(), tags.end(), current_tag) != tags.end()) { // the room has this tag it->second->addRoom(room_id); diff --git a/src/Utils.cpp b/src/Utils.cpp index 7228faf4..3bb090df 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -388,8 +388,9 @@ utils::escapeBlacklistedHtml(const QString &rawStr) switch (data.at(pos)) { case '<': { bool oneTagMatched = false; - const int endPos = static_cast(std::min(static_cast(data.indexOf('>', pos)), - static_cast(data.indexOf(' ', pos)))); + const int endPos = + static_cast(std::min(static_cast(data.indexOf('>', pos)), + static_cast(data.indexOf(' ', pos)))); auto mid = data.mid(pos + 1, endPos - pos - 1); for (const auto &tag : allowedTags) { diff --git a/src/popups/SuggestionsPopup.cpp b/src/popups/SuggestionsPopup.cpp index 42efe6ce..8add4313 100644 --- a/src/popups/SuggestionsPopup.cpp +++ b/src/popups/SuggestionsPopup.cpp @@ -150,7 +150,8 @@ SuggestionsPopup::removeLayoutItemsAfter(size_t startingPos) size_t posToRemove = layout_->count() - 1; QLayoutItem *item; - while (startingPos <= posToRemove && (item = layout_->takeAt((int)posToRemove)) != nullptr) { + while (startingPos <= posToRemove && + (item = layout_->takeAt((int)posToRemove)) != nullptr) { delete item->widget(); delete item; diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index a71e95d5..c6b39742 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -29,7 +29,8 @@ public: friend uint qHash(const Index &i, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; - seed = hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); + seed = + hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); seed = hash(seed, i.idx); return seed; } @@ -46,7 +47,8 @@ public: friend uint qHash(const IdIndex &i, uint seed = 0) noexcept { QtPrivate::QHashCombine hash; - seed = hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); + seed = + hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size())); seed = hash(seed, QByteArray::fromRawData(i.id.data(), (int)i.id.size())); return seed; }