mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
setCurrentArticle(): return false if the article doesn't exist
201f11e656
missed this possibility and may
have inadvertently changed the application behavior in a corner case.
This commit is contained in:
parent
99982a1c11
commit
10d0d8193b
|
@ -760,19 +760,19 @@ bool ArticleView::setCurrentArticle( QString const & id, bool moveToIt )
|
|||
return false; // No action on background page, scrollIntoView there don't work
|
||||
|
||||
QString const dictionaryId = dictionaryIdFromScrollTo( id );
|
||||
if ( getArticlesList().contains( dictionaryId ) )
|
||||
{
|
||||
if ( moveToIt )
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript( QString( "document.getElementById('%1').scrollIntoView(true);" ).arg( id ) );
|
||||
if( !getArticlesList().contains( dictionaryId ) )
|
||||
return false;
|
||||
|
||||
QMap< QString, QVariant > userData = ui.definition->history()->
|
||||
currentItem().userData().toMap();
|
||||
userData[ "currentArticle" ] = id;
|
||||
ui.definition->history()->currentItem().setUserData( userData );
|
||||
if ( moveToIt )
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript( QString( "document.getElementById('%1').scrollIntoView(true);" ).arg( id ) );
|
||||
|
||||
QMap< QString, QVariant > userData = ui.definition->history()->currentItem().userData().toMap();
|
||||
userData[ "currentArticle" ] = id;
|
||||
ui.definition->history()->currentItem().setUserData( userData );
|
||||
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript(
|
||||
QString( "gdMakeArticleActive( '%1' );" ).arg( dictionaryId ) );
|
||||
|
||||
ui.definition->page()->mainFrame()->evaluateJavaScript(
|
||||
QString( "gdMakeArticleActive( '%1' );" ).arg( dictionaryId ) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue