Skip to content

Commit

Permalink
optimize propagated string error
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and nyalldawson committed Jan 11, 2022
1 parent 65debd1 commit eae93a1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -4975,8 +4975,7 @@ void QgisApp::initLayerTreeView()
connect( mMapCanvas, &QgsMapCanvas::renderErrorOccurred, badLayerIndicatorProvider, &QgsLayerTreeViewBadLayerIndicatorProvider::reportLayerError );
connect( mMapCanvas, &QgsMapCanvas::renderErrorOccurred, mInfoBar, [this]( const QString & error, QgsMapLayer * layer )
{
QString message = layer->name() + QStringLiteral( ": " ) + error;
mInfoBar->pushItem( new QgsMessageBarItem( message, Qgis::MessageLevel::Warning, 60 ) );
mInfoBar->pushItem( new QgsMessageBarItem( layer->name(), QgsStringUtils::insertLinks( error ), Qgis::MessageLevel::Warning ) );
} );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgslayertreeviewbadlayerindicator.cpp
Expand Up @@ -82,7 +82,7 @@ void QgsLayerTreeViewBadLayerIndicatorProvider::onIndicatorClicked( const QModel
QgsMessageViewer *m = new QgsMessageViewer( QgisApp::instance() );
m->setWindowTitle( tr( "Layer Error" ) );
if ( thisLayerErrors.count() == 1 )
m->setMessageAsHtml( thisLayerErrors.at( 0 ) );
m->setMessageAsPlainText( thisLayerErrors.at( 0 ) );
else
{
QString message = QStringLiteral( "<ul>" );
Expand Down
8 changes: 5 additions & 3 deletions src/core/vectortile/qgsvectortileloader.cpp
Expand Up @@ -132,9 +132,11 @@ void QgsVectorTileLoader::tileReplyFinished()
{
if ( reply->error() == QNetworkReply::ContentAccessDenied )
{
mError = tr( "Access denied" );
if ( !reply->data().isEmpty() )
mError.append( QStringLiteral( ": " ) + reply->data() );

if ( reply->data().isEmpty() )
mError = tr( "Access denied" );
else
mError = tr( "Access denied: %1" ).arg( QString( reply->data() ) );
}

QgsDebugMsg( QStringLiteral( "Tile download failed! " ) + reply->errorString() );
Expand Down
11 changes: 2 additions & 9 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1049,15 +1049,8 @@ void QgsMapCanvas::notifyRendererErrors( const QgsMapRendererJob::Errors &errors

mRendererErrors[errorKey] = currentTime;

QString message = error.message;
const QRegularExpression regEx( QStringLiteral( "(https?:\\/\\/+[\\/\\{\\}\\?=a-zA-Z0-9_.~-]*)" ), QRegularExpression::CaseInsensitiveOption );
QRegularExpressionMatch match = regEx.match( message );
if ( match.hasMatch() )
message.replace( regEx, "<a href=\"\\1\">\\1</a>" );

QgsMapLayer *layer = QgsProject::instance()->mapLayer( error.layerID );
emit renderErrorOccurred( message, layer );
QgsMessageLog::logMessage( error.layerID + " :: " + message, tr( "Rendering" ) );
if ( QgsMapLayer *layer = QgsProject::instance()->mapLayer( error.layerID ) )
emit renderErrorOccurred( error.message, layer );
}
}

Expand Down

0 comments on commit eae93a1

Please sign in to comment.