diff options
| author | Christian Stenger <christian.stenger@qt.io> | 2025-10-14 13:07:44 +0200 |
|---|---|---|
| committer | Christian Stenger <christian.stenger@qt.io> | 2025-10-17 04:01:30 +0000 |
| commit | 824bf5b55d58d70f6b873294bbdec04445e0960e (patch) | |
| tree | ba02e736312308e4c5814679e117e0f30bcf5f68 /src/plugins/ctfvisualizer/ctfvisualizertool.cpp | |
| parent | 957bdcc8d2e368f72843becc6f6ccda5a9a3aeb3 (diff) | |
CtfVisualizer: Deselect current event on filtering
Using the filter invalidates the order or may even remove the
model used by the current selected event.
Using next or previous afterwards can result in crashes when
accessing the model or item by id as these now point to
different models or items or even non-existing objects.
Invalidate event selections to avoid these crashes.
Change-Id: Ia80fa289f9ecbfd4bceabd60688a40149ac6324d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/ctfvisualizer/ctfvisualizertool.cpp')
| -rw-r--r-- | src/plugins/ctfvisualizer/ctfvisualizertool.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/ctfvisualizer/ctfvisualizertool.cpp b/src/plugins/ctfvisualizer/ctfvisualizertool.cpp index 8b35e2b8d5e..1c1a9415b10 100644 --- a/src/plugins/ctfvisualizer/ctfvisualizertool.cpp +++ b/src/plugins/ctfvisualizer/ctfvisualizertool.cpp @@ -24,6 +24,7 @@ #include <QFileDialog> #include <QMenu> #include <QMessageBox> +#include <QQuickItem> #include <fstream> @@ -157,6 +158,15 @@ void CtfVisualizerTool::setAvailableThreads(const QList<CtfTimelineModel *> &thr void CtfVisualizerTool::toggleThreadRestriction(QAction *action) { const QString tid = action->data().toString(); + + // deselect possibly current event + // (avoids crashes as next / previous would act afterwards on different or even nullptr models) + if (auto root = m_traceView->rootObject()) { + QMetaObject::invokeMethod(root, "selectByIndices", + Q_ARG(QVariant, QVariant(-1)), + Q_ARG(QVariant, QVariant(-1))); + } + m_traceManager->setThreadRestriction(tid, action->isChecked()); } |
