Fix some undefined behaviour

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
(cherry picked from commit bf1084d7fa6503b65bdb63374e5f92020ae4a3d1)
This commit is contained in:
Trial97 2025-02-11 10:59:10 +02:00 committed by github-actions[bot]
parent e2526c80c8
commit 9616d898d4
4 changed files with 18 additions and 18 deletions

View File

@ -113,14 +113,14 @@ if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebI
else() else()
# AppleClang and Clang # AppleClang and Clang
message(STATUS "Address Sanitizer available on Clang") message(STATUS "Address Sanitizer available on Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=null")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=null")
endif() endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GCC # GCC
message(STATUS "Address Sanitizer available on GCC") message(STATUS "Address Sanitizer available on GCC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover")
link_libraries("asan") link_libraries("asan")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(STATUS "Address Sanitizer available on MSVC") message(STATUS "Address Sanitizer available on MSVC")

View File

@ -32,12 +32,12 @@ class LogModel : public QAbstractListModel {
private /* types */: private /* types */:
struct entry { struct entry {
MessageLevel::Enum level; MessageLevel::Enum level = MessageLevel::Enum::Unknown;
QString line; QString line = {};
}; };
private: /* data */ private: /* data */
QVector<entry> m_content; QVector<entry> m_content = {};
int m_maxLines = 1000; int m_maxLines = 1000;
// first line in the circular buffer // first line in the circular buffer
int m_firstLine = 0; int m_firstLine = 0;

View File

@ -40,7 +40,7 @@ class CheckComboModel : public QIdentityProxyModel {
{ {
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString(); auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString();
return checked.contains(txt) ? Qt::Checked : Qt::Unchecked; return m_checked.contains(txt) ? Qt::Checked : Qt::Unchecked;
} }
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
return QIdentityProxyModel::data(index, Qt::DisplayRole); return QIdentityProxyModel::data(index, Qt::DisplayRole);
@ -50,10 +50,10 @@ class CheckComboModel : public QIdentityProxyModel {
{ {
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString(); auto txt = QIdentityProxyModel::data(index, Qt::DisplayRole).toString();
if (checked.contains(txt)) { if (m_checked.contains(txt)) {
checked.removeOne(txt); m_checked.removeOne(txt);
} else { } else {
checked.push_back(txt); m_checked.push_back(txt);
} }
emit dataChanged(index, index); emit dataChanged(index, index);
emit checkStateChanged(); emit checkStateChanged();
@ -61,13 +61,13 @@ class CheckComboModel : public QIdentityProxyModel {
} }
return QIdentityProxyModel::setData(index, value, role); return QIdentityProxyModel::setData(index, value, role);
} }
QStringList getChecked() { return checked; } QStringList getChecked() { return m_checked; }
signals: signals:
void checkStateChanged(); void checkStateChanged();
private: private:
QStringList checked; QStringList m_checked = {};
}; };
CheckComboBox::CheckComboBox(QWidget* parent) : QComboBox(parent), m_separator(", ") CheckComboBox::CheckComboBox(QWidget* parent) : QComboBox(parent), m_separator(", ")
@ -92,7 +92,7 @@ void CheckComboBox::setSourceModel(QAbstractItemModel* new_model)
void CheckComboBox::hidePopup() void CheckComboBox::hidePopup()
{ {
if (!containerMousePress) if (!m_containerMousePress)
QComboBox::hidePopup(); QComboBox::hidePopup();
} }
@ -138,7 +138,7 @@ bool CheckComboBox::eventFilter(QObject* receiver, QEvent* event)
} }
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
auto ev = static_cast<QMouseEvent*>(event); auto ev = static_cast<QMouseEvent*>(event);
containerMousePress = ev && view()->indexAt(ev->pos()).isValid(); m_containerMousePress = ev && view()->indexAt(ev->pos()).isValid();
break; break;
} }
case QEvent::Wheel: case QEvent::Wheel:

View File

@ -58,7 +58,7 @@ class CheckComboBox : public QComboBox {
void toggleCheckState(int index); void toggleCheckState(int index);
private: private:
QString m_default_text; QString m_default_text = {};
QString m_separator; QString m_separator = {};
bool containerMousePress; bool m_containerMousePress = false;
}; };