]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix uninitialised value
authorAleix Pol <aleixpol@kde.org>
Tue, 21 Feb 2023 12:13:06 +0000 (13:13 +0100)
committerAleix Pol <aleixpol@kde.org>
Tue, 21 Feb 2023 12:15:37 +0000 (13:15 +0100)
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

src/views/dolphinview.cpp
src/views/dolphinview.h

index a5d40f3971fc33e450593deae71b29f14af0e0a8..7ed141c9cb5f1f94606f1a01ac039116b40c37af 100644 (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;
         }
index cb8953579d8ea6c1d1ed0b54a77401a6174cc652..dbb304f379a94b86faa6eea3d65f6c30cc777a2d 100644 (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;