diff --git a/rpcs3/rpcs3qt/flow_layout.cpp b/rpcs3/rpcs3qt/flow_layout.cpp index 579ae59404..02fcbd1a34 100644 --- a/rpcs3/rpcs3qt/flow_layout.cpp +++ b/rpcs3/rpcs3qt/flow_layout.cpp @@ -79,10 +79,13 @@ flow_layout::~flow_layout() void flow_layout::clear() { - while (QLayoutItem* item = takeAt(0)) + for (QLayoutItem* item : m_item_list) { - delete item->widget(); - delete item; + if (item) + { + delete item->widget(); + delete item; + } } m_item_list.clear(); m_positions.clear(); @@ -185,8 +188,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const int x = effectiveRect.x(); int y = effectiveRect.y(); int lineHeight = 0; - int rows = 0; - int cols = 0; + int row_count = 0; + int col_count = 0; if (m_dynamic_spacing) { @@ -259,8 +262,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const pos.row = row; pos.col = col++; - rows = std::max(rows, pos.row + 1); - cols = std::max(cols, pos.col + 1); + row_count = std::max(row_count, pos.row + 1); + col_count = std::max(col_count, pos.col + 1); if (!testOnly) item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); @@ -269,8 +272,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const lineHeight = qMax(lineHeight, item->sizeHint().height()); } - m_rows = rows; - m_cols = cols; + m_rows = row_count; + m_cols = col_count; return y + lineHeight - rect.y() + bottom; } diff --git a/rpcs3/rpcs3qt/gui_save.h b/rpcs3/rpcs3qt/gui_save.h index 66970172f6..cbeec7b5a6 100644 --- a/rpcs3/rpcs3qt/gui_save.h +++ b/rpcs3/rpcs3qt/gui_save.h @@ -11,16 +11,11 @@ struct gui_save gui_save() { - key = ""; - name = ""; - def = QVariant(); } gui_save(const QString& k, const QString& n, const QVariant& d) + : key(k), name(n), def(d) { - key = k; - name = n; - def = d; } bool operator==(const gui_save& rhs) const noexcept diff --git a/rpcs3/rpcs3qt/user_account.h b/rpcs3/rpcs3qt/user_account.h index 46991f7565..dd2e1a3d3c 100644 --- a/rpcs3/rpcs3qt/user_account.h +++ b/rpcs3/rpcs3qt/user_account.h @@ -14,9 +14,9 @@ class user_account public: explicit user_account(const std::string& user_id = "00000001"); - std::string GetUserId() const { return m_user_id; } - std::string GetUserDir() const { return m_user_dir; } - std::string GetUsername() const { return m_username; } + const std::string& GetUserId() const { return m_user_id; } + const std::string& GetUserDir() const { return m_user_dir; } + const std::string& GetUsername() const { return m_username; } static std::map GetUserAccounts(const std::string& base_dir); diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 42c900898f..f01e558e92 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -989,14 +989,14 @@ template requires (std::is_integral_v; constexpr bool is_to_signed = std::is_signed_v; - constexpr auto from_mask = is_from_signed > is_to_signed ? UnFrom{umax} >> 1 : UnFrom{umax}; - constexpr auto to_mask = is_to_signed > is_from_signed ? UnTo{umax} >> 1 : UnTo{umax}; + constexpr auto from_mask = (is_from_signed && !is_to_signed) ? UnFrom{umax} >> 1 : UnFrom{umax}; + constexpr auto to_mask = (is_to_signed && !is_from_signed) ? UnTo{umax} >> 1 : UnTo{umax}; constexpr auto mask = ~(from_mask & to_mask); // Signed to unsigned always require test // Otherwise, this is bit-wise narrowing or conversion between types of different signedness of the same size - if constexpr (is_from_signed > is_to_signed || to_mask < from_mask) + if constexpr ((is_from_signed && !is_to_signed) || to_mask < from_mask) { // Try to optimize test if both are of the same signedness if (is_from_signed != is_to_signed ? !!(value & mask) : static_cast(value) != value) [[unlikely]]