Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Prefab window is not reopening after being closed #748 #750

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/src/resources/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Font::requestCharacters(const string &characters) {

if(isNew) {
packSheets(1);
//notifyCurrentState();
notifyCurrentState();
}
}
/*!
Expand Down
3 changes: 1 addition & 2 deletions engine/src/resources/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Resource::Resource(const Resource &origin) :
}

Resource::~Resource() {
assert(m_referenceCount == 0);
//assert(m_referenceCount == 0);

Engine::resourceSystem()->deleteFromCahe(this);
}
Expand Down Expand Up @@ -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);
Expand Down
25 changes: 15 additions & 10 deletions engine/src/resources/sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
2 changes: 1 addition & 1 deletion engine/src/systems/resourcesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions modules/editor/texteditor/editor/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion modules/editor/texturetools/converter/textureconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void TextureConverter::convertSprite(Sprite *sprite, TextureImportSettings *sett

int i = 0;
for(auto &it : settings->elements().keys()) {
Mesh *mesh = Engine::objectCreate<Mesh>(it.toStdString(), sprite);
Mesh *mesh = Engine::objectCreate<Mesh>(it.toStdString());
if(mesh) {
auto value = settings->elements().value(it);

Expand Down
4 changes: 4 additions & 0 deletions modules/editor/texturetools/editor/textureedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions worldeditor/src/main/documentmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Loading