mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
Fix unhandled exceptions at resources loading
This commit is contained in:
parent
9cd66846cb
commit
afaa0a70ab
|
@ -863,30 +863,39 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
||||||
if ( activeDicts )
|
if ( activeDicts )
|
||||||
for( unsigned x = 0; x < activeDicts->size(); ++x )
|
for( unsigned x = 0; x < activeDicts->size(); ++x )
|
||||||
{
|
{
|
||||||
sptr< Dictionary::DataRequest > req =
|
try
|
||||||
(*activeDicts)[ x ]->getResource(
|
|
||||||
url.path().mid( 1 ).toUtf8().data() );
|
|
||||||
|
|
||||||
if ( req->isFinished() && req->dataSize() >= 0 )
|
|
||||||
{
|
{
|
||||||
// A request was instantly finished with success.
|
sptr< Dictionary::DataRequest > req =
|
||||||
// If we've managed to spawn some lingering requests already,
|
(*activeDicts)[ x ]->getResource(
|
||||||
// erase them.
|
url.path().mid( 1 ).toUtf8().data() );
|
||||||
resourceDownloadRequests.clear();
|
|
||||||
|
|
||||||
// Handle the result
|
if ( req->isFinished() && req->dataSize() >= 0 )
|
||||||
resourceDownloadRequests.push_back( req );
|
{
|
||||||
resourceDownloadFinished();
|
// A request was instantly finished with success.
|
||||||
|
// If we've managed to spawn some lingering requests already,
|
||||||
|
// erase them.
|
||||||
|
resourceDownloadRequests.clear();
|
||||||
|
|
||||||
return;
|
// Handle the result
|
||||||
|
resourceDownloadRequests.push_back( req );
|
||||||
|
resourceDownloadFinished();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ( !req->isFinished() )
|
||||||
|
{
|
||||||
|
resourceDownloadRequests.push_back( req );
|
||||||
|
|
||||||
|
connect( req.get(), SIGNAL( finished() ),
|
||||||
|
this, SLOT( resourceDownloadFinished() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch( std::exception & e )
|
||||||
if ( !req->isFinished() )
|
|
||||||
{
|
{
|
||||||
resourceDownloadRequests.push_back( req );
|
emit statusBarMessage(
|
||||||
|
tr( "ERROR: %1" ).arg( e.what() ),
|
||||||
connect( req.get(), SIGNAL( finished() ),
|
10000, QPixmap( ":/icons/error.png" ) );
|
||||||
this, SLOT( resourceDownloadFinished() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1039,11 +1048,19 @@ vector< ResourceToSaveHandler * > ArticleView::saveResource( const QUrl & url, c
|
||||||
{
|
{
|
||||||
for( unsigned x = 0; x < activeDicts->size(); ++x )
|
for( unsigned x = 0; x < activeDicts->size(); ++x )
|
||||||
{
|
{
|
||||||
req = (*activeDicts)[ x ]->getResource(
|
try
|
||||||
url.path().mid( 1 ).toUtf8().data() );
|
{
|
||||||
|
req = (*activeDicts)[ x ]->getResource(
|
||||||
|
url.path().mid( 1 ).toUtf8().data() );
|
||||||
|
|
||||||
ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName );
|
ResourceToSaveHandler * handler = new ResourceToSaveHandler( this, req, fileName );
|
||||||
handlers.push_back( handler );
|
handlers.push_back( handler );
|
||||||
|
}
|
||||||
|
catch( std::exception & e )
|
||||||
|
{
|
||||||
|
qWarning( "getResource request error (%s) in \"%s\"\n", e.what(),
|
||||||
|
(*activeDicts)[ x ]->getName().c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue