From b321204ba2cd39623fdbc313ec60e894d8d75585 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 30 Jun 2018 13:04:32 +0300 Subject: [PATCH] Do not inject clipboard data to Amiga side if AOS is not running (no filesystem heartbeat) --- filesys.cpp | 5 +++++ include/autoconf.h | 1 + od-win32/clipboard_win32.cpp | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/filesys.cpp b/filesys.cpp index d7f0ab8b..66292e2a 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -1863,6 +1863,11 @@ static uae_u32 heartbeat; static int heartbeat_count; static int heartbeat_task; +bool filesys_heartbeat(void) +{ + return heartbeat_count > 0; +} + // This uses filesystem process to reduce resource usage void setsystime (void) { diff --git a/include/autoconf.h b/include/autoconf.h index 4d21a48b..140128dc 100644 --- a/include/autoconf.h +++ b/include/autoconf.h @@ -132,6 +132,7 @@ extern void filesys_start_threads (void); extern void filesys_flush_cache (void); extern void filesys_free_handles (void); extern void filesys_vsync (void); +extern bool filesys_heartbeat(void); extern void filesys_install (void); extern void filesys_install_code (void); diff --git a/od-win32/clipboard_win32.cpp b/od-win32/clipboard_win32.cpp index a1a2e2af..c6051b9f 100644 --- a/od-win32/clipboard_win32.cpp +++ b/od-win32/clipboard_win32.cpp @@ -7,12 +7,14 @@ #include +#include "options.h" #include "traps.h" #include "clipboard_win32.h" #include "clipboard.h" #include "keybuf.h" +#include "memory.h" +#include "autoconf.h" -#include "options.h" #include "threaddep/thread.h" #include "memory.h" #include "native2amiga_api.h" @@ -65,6 +67,8 @@ static void debugwrite (TrapContext *ctx, const TCHAR *name, uaecptr p, int size static uae_u32 to_amiga_start_cb(TrapContext *ctx, void *ud) { + if (!filesys_heartbeat()) + return 0; if (trap_get_long(ctx, clipboard_data) != 0) return 0; if (clipboard_debug) { @@ -751,6 +755,8 @@ static void clipboard_read(TrapContext *ctx, HWND hwnd, bool keyboardinject) #if DEBUG_CLIP > 0 write_log (_T("clipboard: read windows clipboard\n")); #endif + if (!filesys_heartbeat()) + return; if (!OpenClipboard (hwnd)) return; f = 0; @@ -984,6 +990,8 @@ void clipboard_vsync(void) { if (!signaling || !clipboard_data) return; + if (!filesys_heartbeat()) + return; vdelay--; if (vdelay > 0) return; -- 2.47.3