From fc04c8186de8433f89b9167be7c50f543d376e68 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 21 Feb 2023 13:13:06 +0100 Subject: [PATCH] Fix uninitialised value Do not read m_hoveredColumnHearderRoleIndex before it has been initialised. .6 0x00007fe00632182c in QList::Node::t (this=, this=) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:153 .7 QList::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) () from /lib/x86_64-linux-gnu/libQt5Core.so.5 .22 0x00007fe003eba99b in QEventLoop::exec(QFlags) () 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=, argv=) at ./src/main.cpp:249 BUG: 466110 --- src/views/dolphinview.cpp | 6 +++--- src/views/dolphinview.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index a5d40f397..7ed141c9c 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -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; } diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index cb8953579..dbb304f37 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -940,7 +940,7 @@ private: QTimer *m_showLoadingPlaceholderTimer; /// The information roleIndex of the list column header currently hovered - int m_hoveredColumnHearderRoleIndex; + std::optional m_hoveredColumnHearderRoleIndex; /// Used for selection mode. @see setSelectionMode() std::unique_ptr m_proxyStyle; -- 2.47.3