Skip to content

Commit

Permalink
fix linux-specific crash
Browse files Browse the repository at this point in the history
  • Loading branch information
counter185 committed Sep 15, 2024
1 parent 6256046 commit c8449b9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions freesprite/platform_linux.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "EventCallbackListener.h"
#include "Notification.h"
#include "portable-file-dialogs/portable-file-dialogs.h"

//I gave up on trying to make this work
Expand Down Expand Up @@ -45,7 +46,13 @@ void platformTrySaveOtherFile(EventCallbackListener* caller, std::vector<std::pa
std::string filename = result.result();
if (filename.length() > 0) {
//uh oh we need to manually find the filter index
caller->eventFileSaved(evt_id, filename, findIndexByExtension(filetypes, filename));
int index = findIndexByExtension(filetypes, filename);
if (index != -1) {
caller->eventFileSaved(evt_id, filename, index);
}
else {
g_addNotification(ErrorNotification("Linux error", "Please add the extension to the file name"));
}
}
}

Expand All @@ -60,7 +67,13 @@ void platformTryLoadOtherFile(EventCallbackListener* listener, std::vector<std::
std::vector<std::string> filenames = result.result();
if (filenames.size() > 0) {
//uh oh we need to manually find the filter index again
listener->eventFileOpen(evt_id, filenames[0], findIndexByExtension(filetypes, filenames[0]));
int index = findIndexByExtension(filetypes, filenames[0]);
if (index != -1) {
listener->eventFileOpen(evt_id, filenames[0], index);
}
else {
g_addNotification(ErrorNotification("Linux error", "File type could not be found"));
}
}
}

Expand Down

0 comments on commit c8449b9

Please sign in to comment.