Re: [PATCH] kernelshark: make sure ksmodels index is valid before use

Yordan Karadzhov <[email protected]> Sun, 12 Oct 2025 22:42:06 +0300
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
Hi Mircea,

There are two issues with this patch.

First, please provide more detailed instruction how to reproduce the 
problem, because I tried "Pressing Ctrl+C with no data loaded" and I see 
no crash. Nevertheless, the change you suggest looks like a valid fix to me.

The second issue is that the patch itself fails to apply.
My guess is that your Yahoo mail server is messing the text encoding of 
the patch resulting in git rejecting it.

Cheers,
Yordan


On 10/11/25 14:45, Mircea Cirjaliu wrote:
> Pressing Ctrl+C with no data loaded will lead to a crash.
> 
> Signed-off-by: Mircea Cirjaliu <[email protected]>
> ---
>   src/KsModels.cpp | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/KsModels.cpp b/src/KsModels.cpp
> index c8a6ba3..cf4cfe9 100644
> --- a/src/KsModels.cpp
> +++ b/src/KsModels.cpp
> @@ -309,7 +309,8 @@ QVariant KsViewModel::data(const QModelIndex &index, 
> int role) const
>       }
> 
>       if (role == Qt::DisplayRole)
> -        return this->getValue(index.column(), index.row());
> +        if (index.isValid())
> +            return this->getValue(index.column(), index.row());
> 
>       return {};
>   }