Skip to content
Permalink
Browse files
optimize propagated string error
  • Loading branch information
vcloarec authored and nyalldawson committed Jan 11, 2022
1 parent 65debd1 commit eae93a19997156cc0b379fd7b304ea3402770704
Showing with 9 additions and 15 deletions.
  1. +1 −2 src/app/qgisapp.cpp
  2. +1 −1 src/app/qgslayertreeviewbadlayerindicator.cpp
  3. +5 −3 src/core/vectortile/qgsvectortileloader.cpp
  4. +2 −9 src/gui/qgsmapcanvas.cpp
@@ -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 ) );
} );
}

@@ -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>" );
@@ -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() );
@@ -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 );
}
}

0 comments on commit eae93a1

Please sign in to comment.