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:
Igor Kushnir 2022-06-08 19:01:35 +03:00
parent 99982a1c11
commit 10d0d8193b

View file

@ -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;
}