From 98038e34e72004b535f20882cf235264f99bfc9a Mon Sep 17 00:00:00 2001 From: gitlost Date: Fri, 23 Aug 2019 00:56:31 +0100 Subject: [PATCH] Make absolute image filename more Windows friendly --- model/ModelImageObject.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/model/ModelImageObject.cpp b/model/ModelImageObject.cpp index 0eaa068..68d3f2c 100644 --- a/model/ModelImageObject.cpp +++ b/model/ModelImageObject.cpp @@ -538,10 +538,15 @@ namespace glabels } else if ( mFilenameNode.isField() ) { - // Look for image file relative to project file 1st then CWD 2nd then absolute 3rd - auto* model = dynamic_cast( parent() ); - QDir::setSearchPaths( "images", {model->dirPath(), QDir::currentPath(), QDir::rootPath()} ); - QString filename = QString("images:") + mFilenameNode.text( record, variables ); + QString filename = mFilenameNode.text( record, variables ); + QFileInfo fileInfo( filename ); + if ( fileInfo.isRelative() ) + { + // Look for image file relative to project file 1st then CWD 2nd + auto* model = dynamic_cast( parent() ); + QDir::setSearchPaths( "images", {model->dirPath(), QDir::currentPath()} ); + filename = QString("images:") + filename; + } QImage* image; QSvgRenderer* svgRenderer;