Fix memory leak in studio project create

This commit is contained in:
Gary Talent 2017-04-28 13:02:18 -05:00
parent df76f9eb2c
commit be9655c0b1
2 changed files with 10 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -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();
}