From be9655c0b164faf4fcadf3591c611aba8b5bf4d0 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 28 Apr 2017 13:02:18 -0500 Subject: [PATCH] Fix memory leak in studio project create --- src/studio/lib/project.cpp | 10 +++++++--- src/studio/mainwindow.cpp | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/studio/lib/project.cpp b/src/studio/lib/project.cpp index 01c2250a..3dca01f5 100644 --- a/src/studio/lib/project.cpp +++ b/src/studio/lib/project.cpp @@ -23,14 +23,18 @@ Project::Project(QString path) { void Project::create() { QDir().mkpath(m_path); - size_t buffLen = 1024; - m_romBuff = new QByteArray(buffLen, 0); - FileSystem32::format(m_romBuff->data(), buffLen, true); + m_romBuff = new QByteArray(1024, 0); + FileSystem32::format(m_romBuff->data(), m_romBuff->size(), true); + auto fs = ox::fs::createFileSystem(m_romBuff->data(), m_romBuff->size()); + + fs->mkdir("/Tilesets"); QFile file(m_path + "/ROM.oxfs"); file.open(QIODevice::WriteOnly); file.write(*m_romBuff); file.close(); + + delete fs; } } diff --git a/src/studio/mainwindow.cpp b/src/studio/mainwindow.cpp index 224abb95..52acd58a 100644 --- a/src/studio/mainwindow.cpp +++ b/src/studio/mainwindow.cpp @@ -104,11 +104,12 @@ void MainWindow::showNewWizard() { auto projectPath = wizard.field(PROJECT_PATH).toString(); if (QDir(projectPath).exists()) { auto path = projectPath + "/" + projectName; - Project(path).create(); + if (!QDir(path).exists()) { + Project(path).create(); + } } } ); - wizard.resize(width() / 3, height() / 3); wizard.show(); wizard.exec(); }