From f80fbc83486601caa15c6f60e8674732a930d49e Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Sat, 30 Nov 2024 22:38:45 +0100 Subject: [PATCH] Fixed a wrong default type and a crash. The create_file() function was crashing when the user was not selecting any file because and empty path cant be opened. --- file.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/file.py b/file.py index 3a92cb4..5891ce9 100644 --- a/file.py +++ b/file.py @@ -28,13 +28,16 @@ class FileActions: self.app.open_files[file_path] = File(self.app, file_path, file_path.split("/")[-1]) - def create_file(self, content: str=""): + def create_file(self, content: bin=b""): file_path, extension = QFileDialog.getSaveFileName( caption="New File", directory=self.app.utils.home_path, filter="Binary (*.bin);;Any (*)", ) + if file_path == "": + return + if "Binary" in extension: file_path = file_path.split(".")[0] + ".bin" # make sure it has the right extension