From 6273077dbe1bff0a7547029bc5a682a374651f19 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Tue, 24 Apr 2018 04:26:01 -0700 Subject: [PATCH] Fix #35 --- binding-mri/journal-binding.cpp | 15 +++++++++------ install.command | 2 ++ journal/unix/journal.py | 13 +++++++++++-- scripts/Script.rb | 2 ++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/binding-mri/journal-binding.cpp b/binding-mri/journal-binding.cpp index 2902f70..ed01539 100644 --- a/binding-mri/journal-binding.cpp +++ b/binding-mri/journal-binding.cpp @@ -72,12 +72,15 @@ int server_thread(void *data) } CloseHandle(pipe); #else - out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); - active = true; - SDL_LockMutex(mutex); - if (message_len > 0) - write(out_pipe, (char*)message_buffer, message_len); - SDL_UnlockMutex(mutex); + if (FILE *file = fopen(PIPE_PATH, "r")) { + fclose(file); + out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); + SDL_LockMutex(mutex); + active = true; + if (message_len > 0) + write(out_pipe, (char*)message_buffer, message_len); + SDL_UnlockMutex(mutex); + } return 0; #endif } diff --git a/install.command b/install.command index 4f19c8b..bab16f0 100755 --- a/install.command +++ b/install.command @@ -26,5 +26,7 @@ cp -rf "./_______.app" "$ONESHOT_PATH" cp -R "./Graphics/" "$ONESHOT_PATH/Wallpaper" ln -sfh "$ONESHOT_PATH/OneShot.app" "$HOME/Applications/OneShot.app" +rm -f /tmp/oneshot-pipe # Important for pre-release version cleanup + echo "\n${green}Complete! ${white}Please report any issues to https://github.com/vinyldarkscratch/synglechance/issues${color_reset}" open "$ONESHOT_PATH" \ No newline at end of file diff --git a/journal/unix/journal.py b/journal/unix/journal.py index a9fd09b..8340c20 100644 --- a/journal/unix/journal.py +++ b/journal/unix/journal.py @@ -75,6 +75,7 @@ class Journal(QWidget): self.setMinimumSize(800, 600) self.setMaximumSize(800, 600) self.setGeometry(0, 0, 800, 600) + self.show() def mousePressEvent(self, event): @@ -162,12 +163,20 @@ if __name__ == '__main__': save.seek(-8, os.SEEK_END) lang = save.read().decode('utf-8') lang = lang[lang.find('[') + 1:lang.find(']')] - if lang == 'en_US': - lang = 'en' + if lang == 'en_US': lang = 'en' journal.change_image('save_' + lang) else: thread = WatchPipe() thread.change_image.connect(journal.change_image) thread.start() + pipe_file = open(pipe_path, "w+") + pipe_file.close() + app.exec_() + + try: + os.remove(pipe_path) + except: + # Most likely due to the file being in use. Ignore. + pass diff --git a/scripts/Script.rb b/scripts/Script.rb index 02ade60..f3bbc5f 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -450,6 +450,8 @@ module Script end rescue Errno::EACCES => e #this probably means the file already exists and is open, so no need to create it again + rescue Errno::EEXIST => e + #this probably means the file already exists, so no need to create it again end end