Skip to content

Commit

Permalink
Fixes #50892 : Don't enable link in QgsFileWidget if NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed Mar 5, 2023
1 parent 88b840b commit f900bd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/qgsfilewidget.cpp
Expand Up @@ -436,7 +436,7 @@ QString QgsFileWidget::relativePath( const QString &filePath, bool removeRelativ
QString QgsFileWidget::toUrl( const QString &path ) const
{
QString rep;
if ( path.isEmpty() )
if ( path.isEmpty() || path == QgsApplication::nullRepresentation() )
{
return QgsApplication::nullRepresentation();
}
Expand Down
3 changes: 3 additions & 0 deletions tests/src/gui/testqgsfilewidget.cpp
Expand Up @@ -85,6 +85,9 @@ void TestQgsFileWidget::toUrl()
w->setFullUrl( false );
QCOMPARE( w->toUrl( "/home/test2/file5.ext" ), QString( "<a href=\"file:///home/test2/file5.ext\">file5.ext</a>" ) );
QCOMPARE( w->toUrl( "../test2/file6.ext" ), QString( "<a href=\"file:///home/test2/file6.ext\">file6.ext</a>" ) );

QCOMPARE( w->toUrl( QString() ), QgsApplication::nullRepresentation() );
QCOMPARE( w->toUrl( QgsApplication::nullRepresentation() ), QgsApplication::nullRepresentation() );
}

void TestQgsFileWidget::testDroppedFiles()
Expand Down

0 comments on commit f900bd2

Please sign in to comment.