Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
903e9e0c
Commit
903e9e0c
authored
Aug 16, 2022
by
Waqar Ahmed
Browse files
Git: Guard against invalid index
parent
825f693f
Pipeline
#218547
passed with stage
in 6 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
addons/project/branchcheckoutdialog.cpp
View file @
903e9e0c
...
...
@@ -24,7 +24,7 @@ BranchCheckoutDialog::~BranchCheckoutDialog()
void
BranchCheckoutDialog
::
resetValues
()
{
m_checkoutBranchName
.
clear
();
m_checkout
From
BranchName
.
clear
();
m_checkingOutFromBranch
=
false
;
m_lineEdit
.
setPlaceholderText
(
i18n
(
"Select branch to checkout. Press 'Esc' to cancel."
));
}
...
...
@@ -63,7 +63,13 @@ void BranchCheckoutDialog::slotReturnPressed(const QModelIndex &index)
{
// we cleared the model to checkout new branch
if
(
m_model
->
rowCount
()
==
0
)
{
createNewBranch
(
m_lineEdit
.
text
(),
m_checkoutBranchName
);
createNewBranch
(
m_lineEdit
.
text
(),
m_checkoutFromBranchName
);
return
;
}
if
(
!
index
.
isValid
())
{
clearLineEdit
();
hide
();
return
;
}
...
...
@@ -71,7 +77,7 @@ void BranchCheckoutDialog::slotReturnPressed(const QModelIndex &index)
if
(
m_checkingOutFromBranch
)
{
m_checkingOutFromBranch
=
false
;
const
auto
fromBranch
=
index
.
data
(
BranchesDialogModel
::
CheckoutName
).
toString
();
m_checkoutBranchName
=
fromBranch
;
m_checkout
From
BranchName
=
fromBranch
;
m_model
->
clear
();
clearLineEdit
();
m_lineEdit
.
setPlaceholderText
(
i18n
(
"Enter new branch name. Press 'Esc' to cancel."
));
...
...
addons/project/branchcheckoutdialog.h
View file @
903e9e0c
...
...
@@ -26,7 +26,7 @@ private:
private:
QFutureWatcher
<
GitUtils
::
CheckoutResult
>
m_checkoutWatcher
;
QString
m_checkoutBranchName
;
QString
m_checkout
From
BranchName
;
bool
m_checkingOutFromBranch
=
false
;
};
...
...
addons/project/branchesdialog.cpp
View file @
903e9e0c
...
...
@@ -116,12 +116,14 @@ void BranchesDialog::openDialog(GitUtils::RefType r)
void
BranchesDialog
::
slotReturnPressed
(
const
QModelIndex
&
index
)
{
const
auto
branch
=
index
.
data
().
toString
();
const
auto
itemType
=
(
BranchesDialogModel
::
ItemType
)
index
.
data
(
BranchesDialogModel
::
ItemTypeRole
).
toInt
();
Q_ASSERT
(
itemType
==
BranchesDialogModel
::
BranchItem
);
if
(
index
.
isValid
())
{
const
auto
branch
=
index
.
data
().
toString
();
const
auto
itemType
=
(
BranchesDialogModel
::
ItemType
)
index
.
data
(
BranchesDialogModel
::
ItemTypeRole
).
toInt
();
Q_ASSERT
(
itemType
==
BranchesDialogModel
::
BranchItem
);
m_branch
=
branch
;
Q_EMIT
branchSelected
(
branch
);
m_branch
=
branch
;
Q_EMIT
branchSelected
(
branch
);
}
clearLineEdit
();
hide
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment