Skip to content

Commit

Permalink
Fixed potential crash when handling file reloads (#4154)
Browse files Browse the repository at this point in the history
A crash could occur if a file (usually a map, tileset or world) got
reloaded while no editor was currently open.
  • Loading branch information
bjorn authored Jan 24, 2025
1 parent aca6370 commit 150d9a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Unreleased

* Fixed potential crash when handling file reloads

### Tiled 1.11.1 (11 Jan 2025)

* Releases now ship with support for loading Aseprite images (#4109)
Expand Down
12 changes: 8 additions & 4 deletions src/tiled/documentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,10 @@ bool DocumentManager::reloadDocument(Document *document)
break;
}

if (!isDocumentChangedOnDisk(currentDocument()))
mFileChangedWarning->setVisible(false);
// We may need to hide the file changed warning
if (auto current = currentDocument())
if (!isDocumentChangedOnDisk(current))
mFileChangedWarning->setVisible(false);

emit documentReloaded(document);

Expand Down Expand Up @@ -1172,8 +1174,10 @@ void DocumentManager::fileChanged(const QString &fileName)

document->setChangedOnDisk(true);

if (isDocumentChangedOnDisk(currentDocument()))
mFileChangedWarning->setVisible(true);
// We may need to show the file changed warning
if (auto current = currentDocument())
if (isDocumentChangedOnDisk(current))
mFileChangedWarning->setVisible(true);
}

void DocumentManager::hideChangedWarning()
Expand Down

0 comments on commit 150d9a8

Please sign in to comment.