Skip to content

Commit

Permalink
Fixed a crash when selecting a character with no images
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilInTheGaps committed Nov 8, 2023
1 parent dfe43a0 commit 1d271b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/tools/characters/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ Character::Character(const QString &name, QObject *parent) : QObject(parent), a_

Character::Type Character::type() const
{
if (m_files.isEmpty()) return Type::Unknown;
if (m_files.isEmpty())
{
// characters of type image might not have been loaded yet
return m_wasLoaded ? Type::Unknown : Type::Image;
}

if (m_files.first()->name().endsWith("pdf"_L1)) return Type::Pdf;

Expand Down
9 changes: 8 additions & 1 deletion src/tools/characters/charactertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@ void CharacterTool::setCurrentCharacter(qsizetype index)
{
m_currentViewer = &m_imageViewer;
}
else
{
m_currentViewer = nullptr;
}

m_currentViewer->setCharacter(m_currentCharacter);
if (m_currentViewer)
{
m_currentViewer->setCharacter(m_currentCharacter);
}
}

emit currentCharacterChanged();
Expand Down

0 comments on commit 1d271b4

Please sign in to comment.