From b85e2ff66b367b32f99e0e32cd04e765177713b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Clet?= Date: Sat, 17 Aug 2024 13:02:53 +0200 Subject: [PATCH] protection against wrongly addressed write messages --- code/tc.preset.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/code/tc.preset.js b/code/tc.preset.js index aab38e3..5518a47 100644 --- a/code/tc.preset.js +++ b/code/tc.preset.js @@ -105,6 +105,7 @@ var shift_hold, option_hold = 0; var is_interpolating = 0; var is_dragging = 0; // Drag flag var drag_slot = -1; // Stores the slot that's being dragged +var is_writing = 0; // Keeping track of various variables for dealing with color modes var requested_slot = -1; // Which slot we're waiting a value for (used in get_all_preset_colors) @@ -929,14 +930,20 @@ function lockedslots() { } function write() { - var args = arrayfromargs(arguments); - var filename = args[0]; - var state = args[1]; - if (state) { - post(pattrstorage_name + ' pattrstorage: ' + filename + ' updated\n'); + if (is_writing) { + is_writing = 0; + var args = arrayfromargs(arguments); + var filename = args[0]; + var state = args[1]; + if (state) { + post(pattrstorage_name + ' pattrstorage: ' + filename + ' updated\n'); + } else { + error(pattrstorage_name + ': error while writing ' + filename + '\n'); + } } else { - error(pattrstorage_name + ': error while writing ' + filename + '\n'); + error("Send your write messages directly to the pattrstorage instead.\n"); } + } function read() { @@ -1091,6 +1098,7 @@ function set_umenu(v) { function trigger_writeagain() { if (auto_writeagain && !is_dragging) { + is_writing = 1; to_pattrstorage("writeagain"); }