Merge pull request #1096 from kiwix/Library_getArchive_doesnt_return_null

This commit is contained in:
Matthieu Gautier 2024-05-01 18:36:17 +02:00 committed by GitHub
commit 49858fffc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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();