Fix uninitialised value

Do not read m_hoveredColumnHearderRoleIndex before it has been
initialised.

.6  0x00007fe00632182c in QList<KFileItemModel::RoleInfo>::Node::t
(this=<optimized out>, this=<optimized out>) at
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:153
.7  QList<KFileItemModel::RoleInfo>::at (i=3080252, this=0x7ffdf2e9bba8)
at /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:572
.8  DolphinView::eventFilter (this=0x5584bef25160,
watched=0x5584bef8a300, event=0x7ffdf2e9bd30) at
./src/views/dolphinview.cpp:978
.9  0x00007fe003ebbdda in
QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*,
QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
.10 0x00007fe004b6c782 in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
.11 0x00007fe004b75411 in QApplication::notify(QObject*, QEvent*) ()
from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
.12 0x00007fe003ebc07a in QCoreApplication::notifyInternal2(QObject*,
QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
.13 0x00007fe004b72269 in QApplication::event(QEvent*) () from
/lib/x86_64-linux-gnu/libQt5Widgets.so.5
.14 0x00007fe004b6c793 in QApplicationPrivate::notify_helper(QObject*,
QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
.15 0x00007fe003ebc07a in QCoreApplication::notifyInternal2(QObject*,
QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
.16 0x00007fe003f14e0b in QTimerInfoList::activateTimers() () from
/lib/x86_64-linux-gnu/libQt5Core.so.5
.17 0x00007fe003f15754 in ?? () from
/lib/x86_64-linux-gnu/libQt5Core.so.5
.18 0x00007fe001d20d3b in g_main_context_dispatch () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
.19 0x00007fe001d756c8 in ?? () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
.20 0x00007fe001d1e3e3 in g_main_context_iteration () from
/lib/x86_64-linux-gnu/libglib-2.0.so.0
.21 0x00007fe003f15ad8 in
QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)
() from /lib/x86_64-linux-gnu/libQt5Core.so.5
.22 0x00007fe003eba99b in
QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from
/lib/x86_64-linux-gnu/libQt5Core.so.5
.23 0x00007fe003ec2f34 in QCoreApplication::exec() () from
/lib/x86_64-linux-gnu/libQt5Core.so.5
.24 0x00005584bd2a9aad in main (argc=<optimized out>, argv=<optimized
out>) at ./src/main.cpp:249

BUG: 466110
This commit is contained in:
Aleix Pol 2023-02-21 13:13:06 +01:00
parent acf00933f3
commit fc04c8186d
2 changed files with 4 additions and 4 deletions

View file

@ -216,7 +216,7 @@ DolphinView::DolphinView(const QUrl &url, QWidget *parent)
});
connect(m_view, &DolphinItemListView::columnUnHovered, this, [this](int roleIndex) {
Q_UNUSED(roleIndex)
m_hoveredColumnHearderRoleIndex = -1;
m_hoveredColumnHearderRoleIndex = std::nullopt;
});
connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished, this, &DolphinView::slotHeaderColumnWidthChangeFinished);
connect(m_view->header(), &KItemListHeader::sidePaddingChanged, this, &DolphinView::slotSidePaddingWidthChanged);
@ -974,8 +974,8 @@ bool DolphinView::eventFilter(QObject *watched, QEvent *event)
if (tryShowNameToolTip(helpEvent)) {
return true;
} else if (m_hoveredColumnHearderRoleIndex != -1) {
const auto roleInfo = KFileItemModel::rolesInformation().at(m_hoveredColumnHearderRoleIndex);
} else if (m_hoveredColumnHearderRoleIndex) {
const auto roleInfo = KFileItemModel::rolesInformation().at(*m_hoveredColumnHearderRoleIndex);
QToolTip::showText(helpEvent->globalPos(), roleInfo.tooltip, this);
return true;
}

View file

@ -940,7 +940,7 @@ private:
QTimer *m_showLoadingPlaceholderTimer;
/// The information roleIndex of the list column header currently hovered
int m_hoveredColumnHearderRoleIndex;
std::optional<int> m_hoveredColumnHearderRoleIndex;
/// Used for selection mode. @see setSelectionMode()
std::unique_ptr<QProxyStyle> m_proxyStyle;