Skip to content

Commit

Permalink
Avoid triggering Qt warnings about empty file names
Browse files Browse the repository at this point in the history
Sometimes it may happen that we try to load an image even though the
file name is empty. Just return early from these functions in that case.
  • Loading branch information
bjorn committed Jun 24, 2020
1 parent f8da3b5 commit a847d5b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libtiled/imagecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ QHash<TilesheetParameters, CutTiles> ImageCache::sCutTiles;

LoadedImage ImageCache::loadImage(const QString &fileName)
{
if (fileName.isEmpty())
return {};

auto it = sLoadedImages.find(fileName);

QFileInfo info(fileName);
Expand All @@ -127,6 +130,9 @@ LoadedImage ImageCache::loadImage(const QString &fileName)

QPixmap ImageCache::loadPixmap(const QString &fileName)
{
if (fileName.isEmpty())
return {};

auto it = sLoadedPixmaps.find(fileName);

bool found = it != sLoadedPixmaps.end();
Expand Down Expand Up @@ -171,6 +177,9 @@ static CutTiles cutTilesImpl(const TilesheetParameters &p)

QVector<QPixmap> ImageCache::cutTiles(const TilesheetParameters &parameters)
{
if (parameters.fileName.isEmpty())
return {};

auto it = sCutTiles.find(parameters);

bool found = it != sCutTiles.end();
Expand Down Expand Up @@ -199,6 +208,9 @@ void ImageCache::remove(const QString &fileName)

QImage ImageCache::renderMap(const QString &fileName)
{
if (fileName.isEmpty())
return {};

static QSet<QString> loadingMaps;

if (loadingMaps.contains(fileName)) {
Expand Down

0 comments on commit a847d5b

Please sign in to comment.