Skip to content

Commit

Permalink
Fixed wrong layer name getting edited when switching maps
Browse files Browse the repository at this point in the history
When double-clicking a layer (which opens the inline editor for renaming
the layer) and then switching to another map, the layer at the same
index in the new map would get the name in the inline editor.

To avoid this, explicitly commit the data before switching the model.

Closes #1396
  • Loading branch information
bjorn committed Nov 14, 2016
1 parent 325b1d3 commit dcd95fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tiled/layerdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,15 @@ void LayerView::setMapDocument(MapDocument *mapDocument)
{
if (mMapDocument) {
mMapDocument->disconnect(this);

QItemSelectionModel *s = selectionModel();
disconnect(s, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
this, SLOT(currentRowChanged(QModelIndex)));

if (QWidget *w = indexWidget(currentIndex())) {
commitData(w);
closeEditor(w, QAbstractItemDelegate::NoHint);
}
}

mMapDocument = mapDocument;
Expand Down

0 comments on commit dcd95fe

Please sign in to comment.