[Backport release-9.x] Fix some undefined behaviour (#3408)

This commit is contained in:
Alexandru Ionut Tripon 2025-02-11 21:11:17 +02:00 committed by GitHub
commit f760f08df6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View File

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

View File

@ -32,7 +32,7 @@ class LogModel : public QAbstractListModel {
private /* types */:
struct entry {
MessageLevel::Enum level;
MessageLevel::Enum level = MessageLevel::Enum::Unknown;
QString line;
};

View File

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

View File

@ -60,5 +60,5 @@ class CheckComboBox : public QComboBox {
private:
QString m_default_text;
QString m_separator;
bool containerMousePress;
bool m_containerMousePress = false;
};