Skip to content

Commit

Permalink
Fixed potential crash when handling file reloads
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 committed Jan 24, 2025
1 parent aca6370 commit 73f5761
Showing 1 changed file with 8 additions and 4 deletions.
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 73f5761

Please sign in to comment.