diff --git a/src/nostalgia/studio/lib/project.cpp b/src/nostalgia/studio/lib/project.cpp index f45f0a86..d4dfebd0 100644 --- a/src/nostalgia/studio/lib/project.cpp +++ b/src/nostalgia/studio/lib/project.cpp @@ -6,7 +6,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include #include #include "project.hpp" @@ -31,23 +30,25 @@ Project::~Project() { void Project::create() { QDir().mkpath(m_path); - m_romBuff = QSharedPointer(new QByteArray(1024, 0)); - FileSystem32::format((uint8_t*) m_romBuff->data(), m_romBuff->size(), true); - m_fs = createFileSystem((uint8_t*) m_romBuff->data(), m_romBuff->size()); + auto buffSize = 1024; + auto buff = new uint8_t[buffSize]; + FileSystem32::format(buff, buffSize, true); + m_fs = createFileSystem(buff, buffSize, true); QFile file(m_path + ROM_FILE); file.open(QIODevice::WriteOnly); - file.write(*m_romBuff); + file.write((const char*) buff); file.close(); } int Project::open() { QFile file(m_path + ROM_FILE); - m_romBuff = QSharedPointer(new QByteArray(file.size(), 0)); + auto buffSize = file.size(); + auto buff = new uint8_t[buffSize]; if (file.exists()) { file.open(QIODevice::ReadOnly); - if (file.read(m_romBuff->data(), file.size()) > 0) { - m_fs = createFileSystem((uint8_t*) m_romBuff->data(), m_romBuff->size()); + if (file.read((char*) buff, buffSize) > 0) { + m_fs = createFileSystem((uint8_t*) buff, buffSize, true); return 0; } else { return 1; @@ -60,7 +61,7 @@ int Project::open() { void Project::save() { QFile file(m_path + ROM_FILE); file.open(QIODevice::WriteOnly); - file.write(*m_romBuff); + file.write((const char*) m_fs->buff(), m_fs->size()); file.close(); } diff --git a/src/nostalgia/studio/lib/project.hpp b/src/nostalgia/studio/lib/project.hpp index 93368577..f50e3a1d 100644 --- a/src/nostalgia/studio/lib/project.hpp +++ b/src/nostalgia/studio/lib/project.hpp @@ -22,7 +22,6 @@ class Project: public QObject { static QString ROM_FILE; QString m_path = ""; - QSharedPointer m_romBuff; ox::FileSystem *m_fs = nullptr; public: