From 10d0d8193b60b8ac5f06973742fdd0fbb1de6a2d Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Wed, 8 Jun 2022 19:01:35 +0300 Subject: [PATCH] setCurrentArticle(): return false if the article doesn't exist 201f11e65638365e7ef996bf43386581ff4bd075 missed this possibility and may have inadvertently changed the application behavior in a corner case. --- articleview.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/articleview.cc b/articleview.cc index 01711cbc..b0e2d1ae 100644 --- a/articleview.cc +++ b/articleview.cc @@ -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; }