aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaluigiWare64 <68647953+WaluigiWare64@users.noreply.github.com>2020-07-22 16:01:18 +0100
committerGitHub <noreply@github.com>2020-07-22 16:01:18 +0100
commitc8e934ce971ff146a9b076388123dc61f9ad1e9a (patch)
tree6b976390842244d556b72c24b3c5c7af58e99cc1
parentfd4775c3ca6437dc3a7c77f38c3ade3aaf6605a8 (diff)
Fix indentation + delete contents
-rw-r--r--src/frontend/qt_sdl/main.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 7dc72de..ca8ebc1 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -993,7 +993,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
QMenu* menu = menubar->addMenu("File");
actOpenROM = menu->addAction("Open ROM...");
- connect(actOpenROM, &QAction::triggered, this, &MainWindow::onOpenFile);
+ connect(actOpenROM, &QAction::triggered, this, &MainWindow::
+ );
//actBootFirmware = menu->addAction("Launch DS menu");
actBootFirmware = menu->addAction("Boot firmware");
@@ -1408,7 +1409,7 @@ std::string extractROM(char* zipName, std::string zipDir){
int err = 0;
zip *z = zip_open(zipName, 0, &err);
- struct zip_stat st;
+ struct zip_stat st;
zip_stat_init(&st);
zip_stat_index(z, 0, 0, &st); //Get information about the file at index 0
@@ -1417,38 +1418,38 @@ std::string extractROM(char* zipName, std::string zipDir){
//Read the compressed file
zip_file *f = zip_fopen_index(z, 0, 0); //Open file at index 0
- zip_fread(f, contents, st.size);
+ zip_fread(f, contents, st.size);
zip_fclose(f);
zip_close(z);
-
- //Write the file (binary mode)
+
+ //Write the file (binary mode)
std::ofstream(zipDir + "/" + st.name, std::ofstream::binary).write(contents, st.size);
-
- return zipDir + "/" + st.name;
+ delete[] contents;
+ return zipDir + "/" + st.name;
}
void MainWindow::onOpenFile()
{
emuThread->emuPause();
- bool romExtracted = false; //No use yet but may be useful later
+ bool romExtracted = false; //No use yet but may be useful later
QString filename = QFileDialog::getOpenFileName(this,
"Open ROM",
Config::LastROMFolder,
"DS ROMs (*.nds *.dsi *.srl *.zip);;GBA ROMs (*.gba *.zip);;Any file (*.*)");
QFileInfo filenameExtLoc = filename;
- if (filenameExtLoc.completeSuffix().toUtf8() == "zip")
- {
- printf("Extracting ROM from ZIP...\n");
- std::string extractRomLoc = extractROM(filename.toUtf8().data(), filenameExtLoc.absolutePath().toUtf8().data());
- printf("Done.\n");
- filename = QString::fromUtf8(extractRomLoc.c_str());
- romExtracted = true;
- }
+ if (filenameExtLoc.completeSuffix().toUtf8() == "zip")
+ {
+ printf("Extracting ROM from ZIP...\n");
+ std::string extractRomLoc = extractROM(filename.toUtf8().data(), filenameExtLoc.absolutePath().toUtf8().data());
+ printf("Done.\n");
+ filename = QString::fromUtf8(extractRomLoc.c_str());
+ romExtracted = true;
+ }
- if (filename.isEmpty())
+ if (filename.isEmpty())
{
emuThread->emuUnpause();
return;