Skip to content

Commit

Permalink
Fixed crash in Edit Commands dialog
Browse files Browse the repository at this point in the history
The Edit Commands dialog would crash when the user tried to change
command properties right after opening the dialog, before selecting any
of the commands.

This change makes sure the widgets are disabled as appropriate when
opening the dialog, when no command is selected yet.

Closes mapeditor#2914
  • Loading branch information
bjorn committed Oct 14, 2020
1 parent 83cd172 commit 8b7eff7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tiled/commandsedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ CommandsEdit::CommandsEdit(const QVector<Command> &commands, QWidget *parent)

connect(mUi->wdBrowseButton, &QPushButton::clicked,
this, &CommandsEdit::browseWorkingDirectory);

updateWidgets(mUi->treeView->currentIndex());
}

CommandsEdit::~CommandsEdit()
Expand Down Expand Up @@ -130,7 +132,7 @@ void CommandsEdit::setWorkingDirectory(const QString &text)

void CommandsEdit::updateWidgets(const QModelIndex &current)
{
bool enable = (current.row() < mModel->rowCount() - 1);
bool enable = current.isValid() && (current.row() < mModel->rowCount() - 1);

mUi->saveBox->setEnabled(enable);
mUi->executableEdit->setEnabled(enable);
Expand Down

0 comments on commit 8b7eff7

Please sign in to comment.