diff --git a/plugins/builtin/source/content/views/view_pattern_data.cpp b/plugins/builtin/source/content/views/view_pattern_data.cpp index 58304224f..2e3260d30 100644 --- a/plugins/builtin/source/content/views/view_pattern_data.cpp +++ b/plugins/builtin/source/content/views/view_pattern_data.cpp @@ -10,6 +10,8 @@ #include #include +#include + namespace hex::plugin::builtin { ViewPatternData::ViewPatternData() : View::Window("hex.builtin.view.pattern_data.name", ICON_VS_DATABASE) { @@ -47,11 +49,7 @@ namespace hex::plugin::builtin { for (auto &[id, drawer] : drawers) drawer->reset(); - const auto §ions = ContentRegistry::PatternLanguage::getRuntime().getSections(); - auto ids = sections | std::views::keys | std::ranges::to>(); - ids.push_back(0); - - for (const auto &id : ids) { + const auto createDefaultDrawer = [this]() { auto drawer = std::make_unique(); drawer->setSelectionCallback([](const pl::ptrn::Pattern *pattern) { @@ -69,7 +67,14 @@ namespace hex::plugin::builtin { drawer->setTreeStyle(m_treeStyle); drawer->enableRowColoring(m_rowColoring); - (*m_patternDrawer)[id] = std::move(drawer); + return drawer; + }; + + const auto §ions = ContentRegistry::PatternLanguage::getRuntime().getSections(); + + (*m_patternDrawer)[0] = createDefaultDrawer(); + for (const auto &id : sections | std::views::keys) { + (*m_patternDrawer)[id] = createDefaultDrawer(); } }); diff --git a/plugins/remote/source/content/helpers/sftp_client.cpp b/plugins/remote/source/content/helpers/sftp_client.cpp index a30e82bfa..7fe0b1d65 100644 --- a/plugins/remote/source/content/helpers/sftp_client.cpp +++ b/plugins/remote/source/content/helpers/sftp_client.cpp @@ -251,7 +251,8 @@ namespace hex::plugin::remote { } } - SFTPClient::RemoteFile::RemoteFile(RemoteFile &&other) noexcept : m_handle(other.m_handle), m_atEOF(other.m_atEOF) { + SFTPClient::RemoteFile::RemoteFile(RemoteFile &&other) noexcept + : m_handle(other.m_handle), m_atEOF(other.m_atEOF), m_mode(other.m_mode) { other.m_handle = nullptr; } SFTPClient::RemoteFile& SFTPClient::RemoteFile::operator=(RemoteFile &&other) noexcept { @@ -259,19 +260,20 @@ namespace hex::plugin::remote { if (m_handle) libssh2_sftp_close(m_handle); m_handle = other.m_handle; m_atEOF = other.m_atEOF; + m_mode = other.m_mode; other.m_handle = nullptr; } return *this; } size_t SFTPClient::RemoteFile::read(std::span buffer) { - auto size = this->size(); + auto dataSize = this->size(); auto offset = this->tell(); - if (offset > size || buffer.empty()) + if (offset > dataSize || buffer.empty()) return 0; - ssize_t n = libssh2_sftp_read(m_handle, reinterpret_cast(buffer.data()), std::min(buffer.size_bytes(), size - offset)); + ssize_t n = libssh2_sftp_read(m_handle, reinterpret_cast(buffer.data()), std::min(buffer.size_bytes(), dataSize - offset)); if (n < 0) return 0; if (n == 0)