Skip to content

Commit

Permalink
Fix crash in demodialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-Beirao committed Sep 24, 2024
1 parent 87c6062 commit d7a3fb8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/demodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ demodialog::demodialog(QString footer_iwad, QStringList footer_files, QWidget *p
files_listWidget = new QTableWidget();
files = getFilePath_possibleFiles();

for (int i = 0; i < MainWindow::pMainWindow->wads_listWidget()->count(); i++)
{
files.append(QFileInfo(MainWindow::pMainWindow->wads_listWidget()->item(i)->data(Qt::ToolTipRole).toString()));
}

std::sort(files.begin(), files.end(), [](QFileInfo p1, QFileInfo p2) { return p1.baseName().toLower() < p2.baseName().toLower(); });
files.erase(std::unique(files.begin(), files.end()), files.end());

Expand Down
10 changes: 9 additions & 1 deletion src/funcs.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "funcs.h"
#include <mainwindow.h>

void openIWADsFolder() // CTRL+O runs this function to open the folder where the IWADs should be placed in
{
Expand All @@ -24,8 +25,15 @@ QFileInfoList getFilePath_possibleFiles()
{
QFileInfoList files;

QDir datafolder_dir(datafolder);
// Find file in pwad tab
QStringList pwads_in_tab;
for (int i = 0; MainWindow::pMainWindow->wads_listWidget()->count(); i++)
{
files.append(QFileInfo(MainWindow::pMainWindow->wads_listWidget()[i].toolTip()));
}

// Find file in datafolder
QDir datafolder_dir(datafolder);
files.append(datafolder_dir.entryInfoList(QStringList() << "*.WAD"
<< "*.DEH"
<< "*.BEX",
Expand Down
5 changes: 3 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ void MainWindow::dropLmp(QString filePath)
{
QStringList args = QProcess::splitCommand(buffer);
bool searching_files = false;
for (int i = 0; i < args.count() - 1; i++)
for (int i = 0; i < args.count(); i++)
{
if (args[i].isEmpty()) continue;
if (args[i][0] == '-') searching_files = false;

if (searching_files)
Expand All @@ -323,7 +324,7 @@ void MainWindow::dropLmp(QString filePath)
footer_files.append(args[i]);
}

if (args[i] == "-iwad")
if (args[i] == "-iwad" && i < args.count() - 1)
{
footer_iwad = args[i + 1];
}
Expand Down

0 comments on commit d7a3fb8

Please sign in to comment.