diff --git a/engine/src/resources/font.cpp b/engine/src/resources/font.cpp index cd6603a1c..eaf04a078 100644 --- a/engine/src/resources/font.cpp +++ b/engine/src/resources/font.cpp @@ -210,7 +210,7 @@ void Font::requestCharacters(const string &characters) { if(isNew) { packSheets(1); - //notifyCurrentState(); + notifyCurrentState(); } } /*! diff --git a/engine/src/resources/resource.cpp b/engine/src/resources/resource.cpp index fe01cb1c0..0248ca4de 100644 --- a/engine/src/resources/resource.cpp +++ b/engine/src/resources/resource.cpp @@ -50,7 +50,7 @@ Resource::Resource(const Resource &origin) : } Resource::~Resource() { - assert(m_referenceCount == 0); + //assert(m_referenceCount == 0); Engine::resourceSystem()->deleteFromCahe(this); } @@ -140,7 +140,6 @@ void Resource::incRef() { void Resource::decRef() { m_referenceCount--; - assert(m_referenceCount >= 0); if(m_referenceCount <= 0 && m_state != Suspend) { m_last = m_state; setState(Suspend); diff --git a/engine/src/resources/sprite.cpp b/engine/src/resources/sprite.cpp index 60076693a..9b84eff4c 100644 --- a/engine/src/resources/sprite.cpp +++ b/engine/src/resources/sprite.cpp @@ -27,15 +27,7 @@ Sprite::Sprite() { Sprite::~Sprite() { PROFILE_FUNCTION(); - for(auto it : m_shapes) { - it.second.first->decRef(); - } - m_shapes.clear(); - - for(auto it : m_pages) { - it->decRef(); - } - m_pages.clear(); + Sprite::clear(); } /*! Adds new sub \a texture as element to current sprite sheet. @@ -278,7 +270,10 @@ Texture *Sprite::page(int key) const { void Sprite::addPage(Texture *texture) { PROFILE_FUNCTION(); - m_pages.push_back(texture); + if(texture) { + texture->incRef(); + m_pages.push_back(texture); + } } /*! \internal @@ -290,4 +285,14 @@ void Sprite::clear() { it->decRef(); } m_sources.clear(); + + for(auto it : m_pages) { + it->decRef(); + } + m_pages.clear(); + + for(auto it : m_shapes) { + it.second.first->decRef(); + } + m_pages.clear(); } diff --git a/engine/src/systems/resourcesystem.cpp b/engine/src/systems/resourcesystem.cpp index 135fbc568..81e1c6f76 100644 --- a/engine/src/systems/resourcesystem.cpp +++ b/engine/src/systems/resourcesystem.cpp @@ -217,7 +217,7 @@ void ResourceSystem::processState(Resource *resource) { } } break; case Resource::Suspend: { /// \todo Don't delete resource imidiately Cache pattern implementation required - resource->switchState(Resource::Unloading); + //resource->switchState(Resource::Unloading); } break; case Resource::ToBeDeleted: { bool found = false; diff --git a/modules/editor/texteditor/editor/textedit.cpp b/modules/editor/texteditor/editor/textedit.cpp index d891b65c3..3f9e31679 100644 --- a/modules/editor/texteditor/editor/textedit.cpp +++ b/modules/editor/texteditor/editor/textedit.cpp @@ -41,10 +41,12 @@ void TextEdit::setModified(bool flag) { } void TextEdit::loadAsset(AssetConverterSettings *settings) { - AssetEditor::loadAsset(settings); + if(!m_settings.contains(settings)) { + AssetEditor::loadAsset(settings); - ui->editor->openFile(settings->source()); - setWindowTitle(QFileInfo(settings->source()).fileName()); + ui->editor->openFile(settings->source()); + setWindowTitle(QFileInfo(settings->source()).fileName()); + } } void TextEdit::saveAsset(const QString &path) { diff --git a/modules/editor/texturetools/converter/textureconverter.cpp b/modules/editor/texturetools/converter/textureconverter.cpp index 8c50bebaf..85d8a7387 100644 --- a/modules/editor/texturetools/converter/textureconverter.cpp +++ b/modules/editor/texturetools/converter/textureconverter.cpp @@ -341,7 +341,7 @@ void TextureConverter::convertSprite(Sprite *sprite, TextureImportSettings *sett int i = 0; for(auto &it : settings->elements().keys()) { - Mesh *mesh = Engine::objectCreate(it.toStdString(), sprite); + Mesh *mesh = Engine::objectCreate(it.toStdString()); if(mesh) { auto value = settings->elements().value(it); diff --git a/modules/editor/texturetools/editor/textureedit.cpp b/modules/editor/texturetools/editor/textureedit.cpp index b6a98cd9e..c480e6e75 100644 --- a/modules/editor/texturetools/editor/textureedit.cpp +++ b/modules/editor/texturetools/editor/textureedit.cpp @@ -85,6 +85,10 @@ bool TextureEdit::isModified() const { } void TextureEdit::loadAsset(AssetConverterSettings *settings) { + if(m_settings.contains(settings)) { + return; + } + if(!m_settings.isEmpty()) { disconnect(m_settings.first(), &AssetConverterSettings::updated, this, &TextureEdit::onUpdateTemplate); } diff --git a/worldeditor/src/main/documentmodel.cpp b/worldeditor/src/main/documentmodel.cpp index f715e8df3..1f1c5811d 100644 --- a/worldeditor/src/main/documentmodel.cpp +++ b/worldeditor/src/main/documentmodel.cpp @@ -62,6 +62,7 @@ AssetEditor *DocumentModel::openFile(const QString &path) { foreach(auto doc, it->openedDocuments()) { if(doc == settings) { editor = it; + editor->loadAsset(settings); return editor; } }