From 7b30621077ceae724d17d89f69881271749ad697 Mon Sep 17 00:00:00 2001 From: dogboydog Date: Mon, 18 Nov 2024 20:47:16 -0500 Subject: [PATCH 1/7] first pass at setting wang set and color from scripting --- src/tiled/mapeditor.cpp | 13 +++++++++++++ src/tiled/mapeditor.h | 6 ++++-- src/tiled/wangdock.cpp | 11 +++++++++++ src/tiled/wangdock.h | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/tiled/mapeditor.cpp b/src/tiled/mapeditor.cpp index 37926b812b..5e5871122f 100644 --- a/src/tiled/mapeditor.cpp +++ b/src/tiled/mapeditor.cpp @@ -1067,11 +1067,24 @@ EditableWangSet *MapEditor::currentWangSet() const return EditableWangSet::get(mWangDock->currentWangSet()); } +void MapEditor::setCurrentWangSet(EditableWangSet *wangSet) +{ + if (!wangSet) { + ScriptManager::instance().throwNullArgError(0); + return; + } + mWangDock->setCurrentWangSet(wangSet->wangSet()); +} + int MapEditor::currentWangColorIndex() const { return mWangDock->currentWangColor(); } +void MapEditor::setCurrentWangColorIndex(int newIndex) +{ + mWangDock->setCurrentWangColor(newIndex); +} AbstractTool *MapEditor::selectedTool() const { return mSelectedTool; diff --git a/src/tiled/mapeditor.h b/src/tiled/mapeditor.h index 7d8d9b81db..70ea042900 100644 --- a/src/tiled/mapeditor.h +++ b/src/tiled/mapeditor.h @@ -74,8 +74,8 @@ class MapEditor final : public Editor Q_PROPERTY(Tiled::TilesetDock *tilesetsView READ tilesetDock CONSTANT) Q_PROPERTY(Tiled::EditableMap *currentBrush READ currentBrush WRITE setCurrentBrush NOTIFY currentBrushChanged) - Q_PROPERTY(Tiled::EditableWangSet *currentWangSet READ currentWangSet NOTIFY currentWangSetChanged) - Q_PROPERTY(int currentWangColorIndex READ currentWangColorIndex NOTIFY currentWangColorIndexChanged) + Q_PROPERTY(Tiled::EditableWangSet *currentWangSet READ currentWangSet WRITE setCurrentWangSet NOTIFY currentWangSetChanged) + Q_PROPERTY(int currentWangColorIndex READ currentWangColorIndex WRITE setCurrentWangColorIndex NOTIFY currentWangColorIndexChanged) Q_PROPERTY(Tiled::MapView *currentMapView READ currentMapView CONSTANT) public: @@ -120,7 +120,9 @@ class MapEditor final : public Editor void setCurrentBrush(EditableMap *editableMap); EditableWangSet *currentWangSet() const; + void setCurrentWangSet(EditableWangSet *wangSet); int currentWangColorIndex() const; + void setCurrentWangColorIndex(int newIndex); void addExternalTilesets(const QStringList &fileNames); diff --git a/src/tiled/wangdock.cpp b/src/tiled/wangdock.cpp index 5ab91b6533..a75d9d5c13 100644 --- a/src/tiled/wangdock.cpp +++ b/src/tiled/wangdock.cpp @@ -384,6 +384,17 @@ int WangDock::currentWangColor() const return color; } +void WangDock::setCurrentWangColor(int colorIndex) +{ + const QModelIndex index = mWangColorModel->colorIndex(colorIndex); + if (!index.isValid()) + return; + QItemSelectionModel *selectionModel = mWangColorView->selectionModel(); + selectionModel->setCurrentIndex(index, + QItemSelectionModel::ClearAndSelect | + QItemSelectionModel::Rows ); +} + void WangDock::editWangSetName(WangSet *wangSet) { const QModelIndex index = wangSetIndex(wangSet); diff --git a/src/tiled/wangdock.h b/src/tiled/wangdock.h index 9f7eb8cb53..c84289e001 100644 --- a/src/tiled/wangdock.h +++ b/src/tiled/wangdock.h @@ -62,7 +62,7 @@ class WangDock : public QDockWidget WangSet *currentWangSet() const { return mCurrentWangSet; } WangId currentWangId() const { return mCurrentWangId; } int currentWangColor() const; - + void setCurrentWangColor(int colorIndex); void editWangSetName(WangSet *wangSet); void editWangColorName(int colorIndex); From 83c09c1207caf870f3bf0c2391f4723061810e46 Mon Sep 17 00:00:00 2001 From: dogboydog Date: Fri, 22 Nov 2024 18:29:06 -0500 Subject: [PATCH 2/7] reuse onColorCaptured for setting wangset color from scripting --- NEWS.md | 1 + docs/scripting-doc/index.d.ts | 8 +++++--- src/tiled/mapeditor.cpp | 2 +- src/tiled/wangcolormodel.cpp | 4 +--- src/tiled/wangdock.cpp | 11 ----------- src/tiled/wangdock.h | 1 - 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5ed9e8ad13..c50833fb69 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ * Scripting: Added `MapEditor.currentBrushChanged` signal * Scripting: Added `tiled.cursor` to create mouse cursor values * Scripting: Added `Tileset.transformationFlags` (#3753) +* Scripting: Make MapEditor.currentWangSet and MapEditor.currentWangColorIndex writeable (#4105) * Fixed saving/loading of custom properties set on worlds (#4025) * Fixed issue with placing tile objects after switching maps (#3497) * Fixed crash when accessing a world through a symlink (#4042) diff --git a/docs/scripting-doc/index.d.ts b/docs/scripting-doc/index.d.ts index 26140ed269..b545346504 100644 --- a/docs/scripting-doc/index.d.ts +++ b/docs/scripting-doc/index.d.ts @@ -4038,11 +4038,12 @@ interface TilesetEditor { readonly collisionEditor: TileCollisionEditor; /** - * Gets the currently selected {@link WangSet} in the "Terrain Sets" view. + * Get or set the currently selected {@link WangSet} in the "Terrain Sets" view. * * @since 1.9 + * Writable since 1.11.1 */ - readonly currentWangSet: WangSet; + currentWangSet: WangSet; /** * The signal emitted when {@link currentWangSet} changes. @@ -4057,8 +4058,9 @@ interface TilesetEditor { * has index 1. * * @since 1.9 + * Writable since 1.11.1 */ - readonly currentWangColorIndex: number; + currentWangColorIndex: number; /** * The signal emitted when {@link currentWangColorIndex} changes. diff --git a/src/tiled/mapeditor.cpp b/src/tiled/mapeditor.cpp index 5e5871122f..e62a0aa96b 100644 --- a/src/tiled/mapeditor.cpp +++ b/src/tiled/mapeditor.cpp @@ -1083,7 +1083,7 @@ int MapEditor::currentWangColorIndex() const void MapEditor::setCurrentWangColorIndex(int newIndex) { - mWangDock->setCurrentWangColor(newIndex); + mWangDock->onColorCaptured(newIndex); } AbstractTool *MapEditor::selectedTool() const { diff --git a/src/tiled/wangcolormodel.cpp b/src/tiled/wangcolormodel.cpp index 28c177df27..866d7d6021 100644 --- a/src/tiled/wangcolormodel.cpp +++ b/src/tiled/wangcolormodel.cpp @@ -42,9 +42,7 @@ WangColorModel::WangColorModel(TilesetDocument *tilesetDocument, QModelIndex WangColorModel::colorIndex(int color) const { - if (mWangSet) - Q_ASSERT(color <= mWangSet->colorCount()); - else + if (!mWangSet || color > mWangSet->colorCount()) return QModelIndex(); return createIndex(color - 1, 0); diff --git a/src/tiled/wangdock.cpp b/src/tiled/wangdock.cpp index a75d9d5c13..5ab91b6533 100644 --- a/src/tiled/wangdock.cpp +++ b/src/tiled/wangdock.cpp @@ -384,17 +384,6 @@ int WangDock::currentWangColor() const return color; } -void WangDock::setCurrentWangColor(int colorIndex) -{ - const QModelIndex index = mWangColorModel->colorIndex(colorIndex); - if (!index.isValid()) - return; - QItemSelectionModel *selectionModel = mWangColorView->selectionModel(); - selectionModel->setCurrentIndex(index, - QItemSelectionModel::ClearAndSelect | - QItemSelectionModel::Rows ); -} - void WangDock::editWangSetName(WangSet *wangSet) { const QModelIndex index = wangSetIndex(wangSet); diff --git a/src/tiled/wangdock.h b/src/tiled/wangdock.h index c84289e001..4c0d82ebcc 100644 --- a/src/tiled/wangdock.h +++ b/src/tiled/wangdock.h @@ -62,7 +62,6 @@ class WangDock : public QDockWidget WangSet *currentWangSet() const { return mCurrentWangSet; } WangId currentWangId() const { return mCurrentWangId; } int currentWangColor() const; - void setCurrentWangColor(int colorIndex); void editWangSetName(WangSet *wangSet); void editWangColorName(int colorIndex); From 179621b9f3e64994d6f9271a7391df86df18eb8f Mon Sep 17 00:00:00 2001 From: dogboydog Date: Sat, 23 Nov 2024 13:56:13 -0500 Subject: [PATCH 3/7] throw script error if invalid color index. also git ignore build --- .gitignore | 1 + src/tiled/mapeditor.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index cb0ed15503..d85e383626 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ default/ *.user* *.creator.* *.autosave +build/ # Visual Studio *.sln diff --git a/src/tiled/mapeditor.cpp b/src/tiled/mapeditor.cpp index e62a0aa96b..2ef9bdeab9 100644 --- a/src/tiled/mapeditor.cpp +++ b/src/tiled/mapeditor.cpp @@ -1083,6 +1083,8 @@ int MapEditor::currentWangColorIndex() const void MapEditor::setCurrentWangColorIndex(int newIndex) { + if(newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "An invalid wang color index was provided")); mWangDock->onColorCaptured(newIndex); } AbstractTool *MapEditor::selectedTool() const From a6670ee08b5a9f41dd0a73db06b39db8979d5ab6 Mon Sep 17 00:00:00 2001 From: dogboydog Date: Mon, 25 Nov 2024 08:37:33 -0500 Subject: [PATCH 4/7] add missing return statements --- src/tiled/mapeditor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tiled/mapeditor.cpp b/src/tiled/mapeditor.cpp index 2ef9bdeab9..1f3554a41d 100644 --- a/src/tiled/mapeditor.cpp +++ b/src/tiled/mapeditor.cpp @@ -1083,8 +1083,14 @@ int MapEditor::currentWangColorIndex() const void MapEditor::setCurrentWangColorIndex(int newIndex) { - if(newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) + if(!mWangDock->currentWangSet()) { + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "No wangset is loaded")); + return; + } + if(newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) { ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "An invalid wang color index was provided")); + return; + } mWangDock->onColorCaptured(newIndex); } AbstractTool *MapEditor::selectedTool() const From fd85a7eac76dffc887d8acced19938a81e9b3343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 29 Nov 2024 17:34:38 +0100 Subject: [PATCH 5/7] Minor adjustments --- NEWS.md | 2 +- docs/scripting-doc/index.d.ts | 10 ++++------ src/tiled/mapeditor.cpp | 13 +++++++------ src/tiled/mapeditor.h | 1 + src/tiled/wangdock.cpp | 2 +- src/tiled/wangdock.h | 3 ++- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/NEWS.md b/NEWS.md index c50833fb69..38f83fd962 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ * Scripting: Added `MapEditor.currentBrushChanged` signal * Scripting: Added `tiled.cursor` to create mouse cursor values * Scripting: Added `Tileset.transformationFlags` (#3753) -* Scripting: Make MapEditor.currentWangSet and MapEditor.currentWangColorIndex writeable (#4105) +* Scripting: Made `MapEditor.currentWangSet` and `MapEditor.currentWangColorIndex` writeable (#4105) * Fixed saving/loading of custom properties set on worlds (#4025) * Fixed issue with placing tile objects after switching maps (#3497) * Fixed crash when accessing a world through a symlink (#4042) diff --git a/docs/scripting-doc/index.d.ts b/docs/scripting-doc/index.d.ts index b545346504..9a59743f69 100644 --- a/docs/scripting-doc/index.d.ts +++ b/docs/scripting-doc/index.d.ts @@ -4038,10 +4038,9 @@ interface TilesetEditor { readonly collisionEditor: TileCollisionEditor; /** - * Get or set the currently selected {@link WangSet} in the "Terrain Sets" view. + * The currently selected {@link WangSet} in the "Terrain Sets" view. * - * @since 1.9 - * Writable since 1.11.1 + * @since 1.9 (writable since 1.11.1) */ currentWangSet: WangSet; @@ -4053,12 +4052,11 @@ interface TilesetEditor { readonly currentWangSetChanged: Signal; /** - * Gets the currently selected Wang color index in the "Terrain Sets" view. + * The currently selected Wang color index in the "Terrain Sets" view. * The value 0 is used to represent the eraser mode, and the first Wang color * has index 1. * - * @since 1.9 - * Writable since 1.11.1 + * @since 1.9 (writable since 1.11.1) */ currentWangColorIndex: number; diff --git a/src/tiled/mapeditor.cpp b/src/tiled/mapeditor.cpp index 1f3554a41d..c99388bace 100644 --- a/src/tiled/mapeditor.cpp +++ b/src/tiled/mapeditor.cpp @@ -281,7 +281,7 @@ MapEditor::MapEditor(QObject *parent) connect(mWangDock, &WangDock::wangColorChanged, mWangBrush, &WangBrush::setColor); connect(mWangBrush, &WangBrush::colorCaptured, - mWangDock, &WangDock::onColorCaptured); + mWangDock, &WangDock::setCurrentWangColor); connect(mTileStampsDock, &TileStampsDock::setStamp, this, &MapEditor::setStamp); @@ -1083,16 +1083,17 @@ int MapEditor::currentWangColorIndex() const void MapEditor::setCurrentWangColorIndex(int newIndex) { - if(!mWangDock->currentWangSet()) { - ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "No wangset is loaded")); + if (!mWangDock->currentWangSet()) { + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "No current Wang set")); return; } - if(newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) { - ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "An invalid wang color index was provided")); + if (newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) { + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "An invalid index was provided")); return; } - mWangDock->onColorCaptured(newIndex); + mWangDock->setCurrentWangColor(newIndex); } + AbstractTool *MapEditor::selectedTool() const { return mSelectedTool; diff --git a/src/tiled/mapeditor.h b/src/tiled/mapeditor.h index 70ea042900..b794460815 100644 --- a/src/tiled/mapeditor.h +++ b/src/tiled/mapeditor.h @@ -121,6 +121,7 @@ class MapEditor final : public Editor EditableWangSet *currentWangSet() const; void setCurrentWangSet(EditableWangSet *wangSet); + int currentWangColorIndex() const; void setCurrentWangColorIndex(int newIndex); diff --git a/src/tiled/wangdock.cpp b/src/tiled/wangdock.cpp index 5ab91b6533..a1b0786ffb 100644 --- a/src/tiled/wangdock.cpp +++ b/src/tiled/wangdock.cpp @@ -678,7 +678,7 @@ void WangDock::onWangIdUsedChanged(WangId wangId) mWangTemplateView->update(index); } -void WangDock::onColorCaptured(int color) +void WangDock::setCurrentWangColor(int color) { const QModelIndex index = mWangColorModel->colorIndex(color); diff --git a/src/tiled/wangdock.h b/src/tiled/wangdock.h index 4c0d82ebcc..42c510bf53 100644 --- a/src/tiled/wangdock.h +++ b/src/tiled/wangdock.h @@ -62,6 +62,7 @@ class WangDock : public QDockWidget WangSet *currentWangSet() const { return mCurrentWangSet; } WangId currentWangId() const { return mCurrentWangId; } int currentWangColor() const; + void editWangSetName(WangSet *wangSet); void editWangColorName(int colorIndex); @@ -87,7 +88,7 @@ public slots: void setCurrentWangSet(WangSet *wangSet); void onCurrentWangIdChanged(WangId wangId); void onWangIdUsedChanged(WangId wangId); - void onColorCaptured(int color); + void setCurrentWangColor(int color); protected: void changeEvent(QEvent *event) override; From 2d0d0ca825e7d2b955b7e41b007da14b54e2bc51 Mon Sep 17 00:00:00 2001 From: dogboydog Date: Fri, 29 Nov 2024 12:07:43 -0500 Subject: [PATCH 6/7] scripting: make current wang set and wang color writeable on tileset editor --- NEWS.md | 2 +- docs/scripting-doc/index.d.ts | 12 ++++++------ src/tiled/tileseteditor.cpp | 23 +++++++++++++++++++++++ src/tiled/tileseteditor.h | 7 +++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 38f83fd962..b0c0f861a7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ * Scripting: Added `MapEditor.currentBrushChanged` signal * Scripting: Added `tiled.cursor` to create mouse cursor values * Scripting: Added `Tileset.transformationFlags` (#3753) -* Scripting: Made `MapEditor.currentWangSet` and `MapEditor.currentWangColorIndex` writeable (#4105) +* Scripting: Made `MapEditor.currentWangSet`, `TilesetEditor.currentWangSet`, `MapEditor.currentWangColorIndex`, and `TilesetEditor.currentWangColorIndex` writeable (#4105) * Fixed saving/loading of custom properties set on worlds (#4025) * Fixed issue with placing tile objects after switching maps (#3497) * Fixed crash when accessing a world through a symlink (#4042) diff --git a/docs/scripting-doc/index.d.ts b/docs/scripting-doc/index.d.ts index 9a59743f69..acc2b85c85 100644 --- a/docs/scripting-doc/index.d.ts +++ b/docs/scripting-doc/index.d.ts @@ -2480,13 +2480,13 @@ interface MapEditor { currentBrushChanged: Signal; /** - * Gets the currently selected {@link WangSet} in the "Terrain Sets" view. + * The currently selected {@link WangSet} in the "Terrain Sets" view. * * See also {@link TileLayerWangEdit}. * - * @since 1.8 + * @since 1.8 (writable since 1.11.1) */ - readonly currentWangSet: WangSet; + currentWangSet: WangSet; /** * The signal emitted when {@link currentWangSet} changes. @@ -2496,15 +2496,15 @@ interface MapEditor { readonly currentWangSetChanged: Signal; /** - * Gets the currently selected Wang color index in the "Terrain Sets" view. + * The currently selected Wang color index in the "Terrain Sets" view. * The value 0 is used to represent the eraser mode, and the first Wang color * has index 1. * * See also {@link TileLayerWangEdit}. * - * @since 1.8 + * @since 1.8 (writable since 1.11.1) */ - readonly currentWangColorIndex: number; + currentWangColorIndex: number; /** * The signal emitted when {@link currentWangColorIndex} changes. diff --git a/src/tiled/tileseteditor.cpp b/src/tiled/tileseteditor.cpp index 07e091c536..9580d9d9ae 100644 --- a/src/tiled/tileseteditor.cpp +++ b/src/tiled/tileseteditor.cpp @@ -37,6 +37,7 @@ #include "objecttemplate.h" #include "preferences.h" #include "propertiesdock.h" +#include "scriptmanager.h" #include "session.h" #include "templatesdock.h" #include "tile.h" @@ -510,11 +511,33 @@ EditableWangSet *TilesetEditor::currentWangSet() const return EditableWangSet::get(mWangDock->currentWangSet()); } +void TilesetEditor::setCurrentWangSet(EditableWangSet *wangSet) +{ + if (!wangSet) { + ScriptManager::instance().throwNullArgError(0); + return; + } + mWangDock->setCurrentWangSet(wangSet->wangSet()); +} + int TilesetEditor::currentWangColorIndex() const { return mWangDock->currentWangColor(); } +void TilesetEditor::setCurrentWangColorIndex(int newIndex) +{ + if (!mWangDock->currentWangSet()) { + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "No current Wang set")); + return; + } + if (newIndex < 0 || newIndex > mWangDock->currentWangSet()->colorCount()) { + ScriptManager::instance().throwError(QCoreApplication::translate("Script Errors", "An invalid index was provided")); + return; + } + mWangDock->setCurrentWangColor(newIndex); +} + void TilesetEditor::currentWidgetChanged() { if (!mWidgetStack->currentWidget()) diff --git a/src/tiled/tileseteditor.h b/src/tiled/tileseteditor.h index 1080dd5e34..5f86bb2f33 100644 --- a/src/tiled/tileseteditor.h +++ b/src/tiled/tileseteditor.h @@ -57,8 +57,8 @@ class TilesetEditor final : public Editor Q_OBJECT Q_PROPERTY(Tiled::TileCollisionDock *collisionEditor READ collisionEditor CONSTANT) - Q_PROPERTY(Tiled::EditableWangSet *currentWangSet READ currentWangSet NOTIFY currentWangSetChanged) - Q_PROPERTY(int currentWangColorIndex READ currentWangColorIndex NOTIFY currentWangColorIndexChanged) + Q_PROPERTY(Tiled::EditableWangSet *currentWangSet READ currentWangSet WRITE setCurrentWangSet NOTIFY currentWangSetChanged) + Q_PROPERTY(int currentWangColorIndex READ currentWangColorIndex WRITE setCurrentWangColorIndex NOTIFY currentWangColorIndexChanged) public: explicit TilesetEditor(QObject *parent = nullptr); @@ -101,7 +101,10 @@ class TilesetEditor final : public Editor TileCollisionDock *collisionEditor() const; EditableWangSet *currentWangSet() const; + void setCurrentWangSet(EditableWangSet *wangSet); + int currentWangColorIndex() const; + void setCurrentWangColorIndex(int newIndex); signals: void currentTileChanged(Tile *tile); From 906f9a9d66a03a2d1c8acaa6554fa23cb2b45084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 29 Nov 2024 21:42:11 +0100 Subject: [PATCH 7/7] Shortened NEWS entry I guess this is enough. --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index b0c0f861a7..d56d93678a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ * Scripting: Added `MapEditor.currentBrushChanged` signal * Scripting: Added `tiled.cursor` to create mouse cursor values * Scripting: Added `Tileset.transformationFlags` (#3753) -* Scripting: Made `MapEditor.currentWangSet`, `TilesetEditor.currentWangSet`, `MapEditor.currentWangColorIndex`, and `TilesetEditor.currentWangColorIndex` writeable (#4105) +* Scripting: Made `currentWangSet` and `currentWangColorIndex` properties writeable (#4105) * Fixed saving/loading of custom properties set on worlds (#4025) * Fixed issue with placing tile objects after switching maps (#3497) * Fixed crash when accessing a world through a symlink (#4042)