Skip to content

Commit

Permalink
Merge pull request #1096 from kiwix/Library_getArchive_doesnt_return_…
Browse files Browse the repository at this point in the history
…null
  • Loading branch information
mgautierfr committed May 1, 2024
2 parents 073dd06 + 0a42126 commit 49858ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ QString Library::openBookFromPath(const QString &zimPath)

std::shared_ptr<zim::Archive> Library::getArchive(const QString &zimId)
{
return mp_library->getArchiveById(zimId.toStdString());
const auto archive = mp_library->getArchiveById(zimId.toStdString());
if ( ! archive ) {
throw std::out_of_range("ZIM file doesn't exist (or cannot be opened)");
}
return archive;
}

std::shared_ptr<zim::Searcher> Library::getSearcher(const QString &zimId)
Expand Down
3 changes: 0 additions & 3 deletions src/readinglistbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ void ReadingListBar::setupList()
} catch (std::out_of_range& e) {
continue;
}
if ( !archive ) {
continue;
}
try {
auto illustration = archive->getIllustrationItem(48);
std::string content = illustration.getData();
Expand Down

0 comments on commit 49858ff

Please sign in to comment.