mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge pull request #878 from shenlebantongying/staged
guard against null img for ZIM
This commit is contained in:
commit
1185e8896f
|
@ -290,7 +290,14 @@ void ZimDictionary::loadIcon() noexcept
|
||||||
try {
|
try {
|
||||||
auto illustration = df.getIllustrationItem( 48 ).getData();
|
auto illustration = df.getIllustrationItem( 48 ).getData();
|
||||||
QImage img = QImage::fromData( reinterpret_cast< const uchar * >( illustration.data() ), illustration.size() );
|
QImage img = QImage::fromData( reinterpret_cast< const uchar * >( illustration.data() ), illustration.size() );
|
||||||
|
|
||||||
|
if ( img.isNull() ) {
|
||||||
|
// Fallback to default icon
|
||||||
|
dictionaryIcon = QIcon( ":/icons/icon32_zim.png" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
dictionaryIcon = QIcon( QPixmap::fromImage( img ) );
|
dictionaryIcon = QIcon( QPixmap::fromImage( img ) );
|
||||||
|
}
|
||||||
|
|
||||||
dictionaryIconLoaded = true;
|
dictionaryIconLoaded = true;
|
||||||
return;
|
return;
|
||||||
|
@ -298,11 +305,6 @@ void ZimDictionary::loadIcon() noexcept
|
||||||
catch ( zim::EntryNotFound & e ) {
|
catch ( zim::EntryNotFound & e ) {
|
||||||
gdDebug( "ZIM icon not loaded for: %s", dictionaryName.c_str() );
|
gdDebug( "ZIM icon not loaded for: %s", dictionaryName.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to default icon
|
|
||||||
dictionaryIcon = QIcon( ":/icons/icon32_zim.png" );
|
|
||||||
|
|
||||||
dictionaryIconLoaded = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 ZimDictionary::loadArticle( quint32 address, string & articleText, bool rawText )
|
quint32 ZimDictionary::loadArticle( quint32 address, string & articleText, bool rawText )
|
||||||
|
|
Loading…
Reference in a new issue