diff --git a/src/tiled/automapper.cpp b/src/tiled/automapper.cpp index f6dd498e86..cbf8d1ea59 100644 --- a/src/tiled/automapper.cpp +++ b/src/tiled/automapper.cpp @@ -639,9 +639,16 @@ void AutoMapper::setupRules() mRules.reserve(combinedRegions.size()); for (const QRegion &combinedRegion : combinedRegions) { + QRegion inputRegion = combinedRegion & regionInput; + QRegion outputRegion = combinedRegion & regionOutput; + + // Skip rules where either input or output region is empty + if (inputRegion.isEmpty() || outputRegion.isEmpty()) + continue; + Rule &rule = mRules.emplace_back(); - rule.inputRegion = combinedRegion & regionInput; - rule.outputRegion = combinedRegion & regionOutput; + rule.inputRegion = std::move(inputRegion); + rule.outputRegion = std::move(outputRegion); rule.options = mRuleOptions; for (const auto &optionsArea : setup.mRuleOptionsAreas) @@ -1474,5 +1481,3 @@ void AutoMapper::addWarning(const QString &message, std::function callb } } // namespace Tiled - -#include "moc_automapper.cpp" diff --git a/src/tiled/automapper.h b/src/tiled/automapper.h index 52a43ad098..a8ca7da548 100644 --- a/src/tiled/automapper.h +++ b/src/tiled/automapper.h @@ -27,6 +27,7 @@ #include "tilelayer.h" #include "tileset.h" +#include #include #include #include @@ -275,9 +276,9 @@ struct TILED_EDITOR_EXPORT AutoMappingContext * - copy regions of Maps (multiple Layers, the layerlist is a * lookup-table for matching the Layers) */ -class TILED_EDITOR_EXPORT AutoMapper : public QObject +class TILED_EDITOR_EXPORT AutoMapper { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(Tiled::AutoMapper) public: struct Options @@ -333,7 +334,7 @@ class TILED_EDITOR_EXPORT AutoMapper : public QObject * AutoMapper takes ownership of this map. */ AutoMapper(std::unique_ptr rulesMap, const QRegularExpression &mapNameFilter = {}); - ~AutoMapper() override; + ~AutoMapper(); QString rulesMapFileName() const; const QRegularExpression &mapNameFilter() const;