Skip to content

Commit

Permalink
Fix backslash interpretation in IconFile and Image statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulat committed Oct 10, 2023
1 parent c5a5668 commit 8326b2f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion scwx-qt/source/scwx/qt/gl/draw/placefile_icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <execution>

#include <QDir>
#include <QUrl>
#include <boost/unordered/unordered_flat_map.hpp>

Expand Down Expand Up @@ -44,7 +45,8 @@ struct PlacefileIconInfo
{
// Resolve using base URL
auto baseUrl = QUrl::fromUserInput(QString::fromStdString(baseUrlString));
auto relativeUrl = QUrl(QString::fromStdString(iconFile->filename_));
auto relativeUrl = QUrl(QDir::fromNativeSeparators(
QString::fromStdString(iconFile->filename_)));
resolvedUrl_ = baseUrl.resolved(relativeUrl).toString().toStdString();
}

Expand Down
6 changes: 4 additions & 2 deletions scwx-qt/source/scwx/qt/gl/draw/placefile_images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <scwx/qt/util/texture_atlas.hpp>
#include <scwx/util/logger.hpp>

#include <QDir>
#include <QUrl>
#include <boost/unordered/unordered_flat_map.hpp>

Expand Down Expand Up @@ -39,8 +40,9 @@ struct PlacefileImageInfo
{
// Resolve using base URL
auto baseUrl = QUrl::fromUserInput(QString::fromStdString(baseUrlString));
auto relativeUrl = QUrl(QString::fromStdString(imageFile));
resolvedUrl_ = baseUrl.resolved(relativeUrl).toString().toStdString();
auto relativeUrl =
QUrl(QDir::fromNativeSeparators(QString::fromStdString(imageFile)));
resolvedUrl_ = baseUrl.resolved(relativeUrl).toString().toStdString();
}

void UpdateTextureInfo();
Expand Down
8 changes: 5 additions & 3 deletions scwx-qt/source/scwx/qt/manager/placefile_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,9 @@ PlacefileManager::Impl::LoadImageResources(
[&baseUrl](auto& iconFile)
{
// Resolve target URL relative to base URL
QUrl fileUrl =
QUrl(QString::fromStdString(iconFile->filename_));
QString filePath =
QString::fromStdString(iconFile->filename_);
QUrl fileUrl = QUrl(QDir::fromNativeSeparators(filePath));
QUrl resolvedUrl = baseUrl.resolved(fileUrl);

return resolvedUrl.toString().toStdString();
Expand All @@ -783,7 +784,8 @@ PlacefileManager::Impl::LoadImageResources(
std::static_pointer_cast<gr::Placefile::ImageDrawItem>(di)
->imageFile_;

QUrl fileUrl = QUrl(QString::fromStdString(imageFile));
QString filePath = QString::fromStdString(imageFile);
QUrl fileUrl = QUrl(QDir::fromNativeSeparators(filePath));
QUrl resolvedUrl = baseUrl.resolved(fileUrl);
std::string urlString = resolvedUrl.toString().toStdString();

Expand Down

0 comments on commit 8326b2f

Please sign in to comment.