Merge pull request #358 from Nheko-Reborn/windows-fixes

Windows fixes
This commit is contained in:
DeepBlueV7.X 2020-12-25 05:59:18 +01:00 committed by GitHub
commit ea5f6ca0f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 138 additions and 107 deletions

View file

@ -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})
@ -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()

View file

@ -2,45 +2,65 @@
"configurations": [
{
"name": "Debug",
"generator": "Visual Studio 15 2017 Win64",
"generator": "Visual Studio 16 2019 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": "HUNTER_ENABLED",
"value": "OFF",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "ON",
"type": "BOOL"
},
{
"name": "CMAKE_INSTALL_PREFIX",
"value": "${workspaceRoot}/.deps"
"value": "${workspaceRoot}/.deps",
"type": "STRING"
},
{
"name": "Qt5_DIR",
"value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here
"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 15 2017 Win64",
"generator": "Visual Studio 16 2019 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": "HUNTER_ENABLED",
"value": "ON",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "OFF",
"type": "BOOL"
},
{
"name": "CMAKE_INSTALL_PREFIX",
"value": "${workspaceRoot}/.deps"
"value": "${workspaceRoot}/.deps",
"type": "STRING"
},
{
"name": "Qt5_DIR",
"value": "C:\\Qt\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" // <-- change qt location here
"value": "C:\\Qt\\5.12.5\\msvc2017_64\\lib\\cmake\\Qt5", // <-- change qt location here
"type": "STRING"
}
]
},
]
],
"cmakeToolchain": "${workspaceRoot}\\toolchain.cmake",
"inheritEnvironments": [ "msvc_x64" ]
}
]
}

View file

@ -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

View file

@ -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()));
});
}

View file

@ -31,7 +31,8 @@ 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();

View file

@ -685,7 +685,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);
}
@ -713,7 +713,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());
}
@ -1267,9 +1267,10 @@ 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());
}
}
}
@ -1468,9 +1469,10 @@ 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());
}
}
@ -1502,9 +1504,10 @@ Cache::getRoomInfo(const std::vector<std::string> &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.
@ -1517,10 +1520,11 @@ Cache::getRoomInfo(const std::vector<std::string> &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()));
nhlog::db()->warn("failed to parse room info for invite: "
"room_id ({}), {}: {}",
room,
std::string(data.data(), data.size()),
e.what());
}
}
}
@ -2053,8 +2057,8 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
}
}
auto cursor = lmdb::cursor::open(txn, membersdb);
const int total = membersdb.size(txn);
auto cursor = lmdb::cursor::open(txn, membersdb);
const auto total = membersdb.size(txn);
std::size_t ii = 0;
std::string user_id;
@ -2337,7 +2341,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<std::string>

View file

@ -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;

View file

@ -439,7 +439,7 @@ ChatPage::bootstrap(QString userid, QString homeserver, QString token)
try {
http::client()->set_user(parse<User>(userid.toStdString()));
} catch (const std::invalid_argument &e) {
} catch (const std::invalid_argument &) {
nhlog::ui()->critical("bootstrapped with invalid user_id: {}",
userid.toStdString());
}

View file

@ -104,7 +104,8 @@ CommunitiesList::setTagsForRoom(const QString &room_id, const std::vector<std::s
}
// insert or remove the room from the tag as appropriate
std::string current_tag =
it->first.right(it->first.size() - strlen("tag:")).toStdString();
it->first.right(static_cast<int>(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 +247,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);

View file

@ -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<int>(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<int>(groupId_.size() - strlen("tag:")));
if (tag == "m.favourite")
setToolTip(tr("Favourite rooms"));
else if (tag == "m.lowpriority")

View file

@ -225,7 +225,7 @@ LoginPage::onMatrixIdEntered()
try {
user = parse<User>(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<User>(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;

View file

@ -164,7 +164,7 @@ MainWindow::MainWindow(QWidget *parent)
try {
using namespace mtx::identifiers;
http::client()->set_user(parse<User>(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());
}
@ -473,7 +473,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());

View file

@ -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",

View file

@ -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;

View file

@ -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<int> row1(hlen + 1, 0);
for (int i = 0; i < nlen; ++i) {
std::vector<int> row2(1, i + 1);
for (size_t i = 0; i < nlen; ++i) {
std::vector<int> 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,16 @@ 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<size_t>(data.indexOf('>', pos)),
static_cast<size_t>(data.indexOf(' ', pos)));
const int endPos =
static_cast<int>(std::min(static_cast<size_t>(data.indexOf('>', pos)),
static_cast<size_t>(data.indexOf(' ', pos))));
auto mid = data.mid(pos + 1, endPos - pos - 1);
for (const auto &tag : allowedTags) {
@ -543,7 +544,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<int>(qAbs(hash % 360));
auto userHue = static_cast<int>(hash % 360);
// start with moderate saturation and lightness values.
auto sat = 220;
auto lightness = 125;

View file

@ -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_);

View file

@ -35,14 +35,14 @@ SuggestionsPopup::addRooms(const std::vector<RoomSearchResult> &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<RoomSearchResult> &rooms)
resetSelection();
adjustSize();
resize(geometry().width(), 40 * rooms.size());
resize(geometry().width(), 40 * (int)rooms.size());
selectNextSuggestion();
}
@ -150,7 +150,8 @@ 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;

View file

@ -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(), i.room.size()));
seed =
hash(seed, QByteArray::fromRawData(i.room.data(), (int)i.room.size()));
seed = hash(seed, i.idx);
return seed;
}
@ -46,8 +47,9 @@ 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;
}

View file

@ -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<QString> &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 "";