mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Do not crash if the zim file is invalid or corrupted.
This commit is contained in:
parent
84e5124ae6
commit
7c8d475d24
@ -19,7 +19,11 @@ void KiwixApp::openZimFile(const QString &zimfile)
|
||||
delete reader;
|
||||
const std::string zimfile_ = zimfile.toLocal8Bit().constData();
|
||||
std::cout << "Opening " << zimfile_ << std::endl;
|
||||
reader = new kiwix::Reader(zimfile_);
|
||||
try {
|
||||
reader = new kiwix::Reader(zimfile_);
|
||||
} catch (...) {
|
||||
reader = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
kiwix::Reader* KiwixApp::getReader()
|
||||
|
@ -20,6 +20,10 @@ KiwixSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
|
||||
zim::Article art;
|
||||
std::cout << "Url is " << url << std::endl;
|
||||
auto reader = static_cast<KiwixApp*>(KiwixApp::instance())->getReader();
|
||||
if ( reader == nullptr) {
|
||||
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||
return;
|
||||
}
|
||||
if ( !reader->getArticleObjectByDecodedUrl(url, art))
|
||||
{
|
||||
url = "A/" + url;
|
||||
|
Loading…
x
Reference in New Issue
Block a user