From 3a845f0f5f6ee58ca3f5d906bf8b313294d33f6e Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Tue, 11 Jun 2024 22:24:17 +0200 Subject: [PATCH] for some reason the stashRef is invalid and then we run into a nullptr exception --- src/ui/ReferenceModel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index 5dbd29b3d..306edb35c 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -106,7 +106,8 @@ void ReferenceModel::update() { // Add bottom references. const bool stashOnCommit = !mCommit.isValid() || - mRepo.stashRef().annotatedCommit().commit() == mCommit; + (mRepo.stashRef().isValid() && + mRepo.stashRef().annotatedCommit().commit() == mCommit); if ((mKinds & ReferenceView::Stash) && stashOnCommit) { if (git::Reference stash = mRepo.stashRef()) branches.append(stash); @@ -180,8 +181,9 @@ QModelIndex ReferenceModel::firstBranch() { // use the first valid ref after the invalid ref but only // it is not the stash if (ref.refs.count() > 1 && - ref.refs.at(1).annotatedCommit().commit() != - mRepo.stashRef().annotatedCommit().commit()) + (!mRepo.stashRef().isValid() || + ref.refs.at(1).annotatedCommit().commit() != + mRepo.stashRef().annotatedCommit().commit())) return createIndex(1, 0, ReferenceType::Branches); } else if (ref.refs.count() > 0) return createIndex(0, 0, ReferenceType::Branches);