Skip to content

Commit

Permalink
Fixed potential crash when removing a tileset
Browse files Browse the repository at this point in the history
When a tileset is removed its view was deleted before the tab was
removed from the tab bar. This could lead to the case where
currentTilesetDocument could return the wrong tileset or crash, even
though currentTilesetView had returned a valid view.

With this change, we make these functions behave consistently, which
hopefully avoids such issues.
  • Loading branch information
bjorn committed Jun 24, 2020
1 parent a847d5b commit 7de5882
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tiled/tilesetdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void TilesetDock::setCurrentTileset(const SharedTileset &tileset)

SharedTileset TilesetDock::currentTileset() const
{
const int index = mTabBar->currentIndex();
const int index = mViewStack->currentIndex();
if (index == -1)
return {};

Expand All @@ -944,7 +944,7 @@ SharedTileset TilesetDock::currentTileset() const

TilesetDocument *TilesetDock::currentTilesetDocument() const
{
const int index = mTabBar->currentIndex();
const int index = mViewStack->currentIndex();
if (index == -1)
return nullptr;

Expand Down

0 comments on commit 7de5882

Please sign in to comment.