From b445f6d6cc096cbbf4d448d64e95ed16fdd599f3 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Sun, 29 Dec 2024 10:27:12 +0000 Subject: [PATCH] Use `defer_low` for read, write, print, load, dump (#438) `defer_low` is needed to properly deal with dialog boxes, it turns out, so `read, write` needed changing. The others are changed to minimize surprise, i.e. `(read, print)` should still work as expected, i.e. sequentially. `load / dump` maybe don't need to change, but I can imagine `(read, dump)` calls --- source/include/FluidMaxWrapper.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/include/FluidMaxWrapper.hpp b/source/include/FluidMaxWrapper.hpp index 100cc79b..c99a30c7 100644 --- a/source/include/FluidMaxWrapper.hpp +++ b/source/include/FluidMaxWrapper.hpp @@ -2068,7 +2068,7 @@ class FluidMaxWrapper template static void deferLoad(FluidMaxWrapper* x, t_symbol*, long ac, t_atom* av) { - defer(x, (method) doLoad, nullptr, static_cast(ac), av); + defer_low(x, (method) doLoad, nullptr, static_cast(ac), av); } template @@ -2120,7 +2120,7 @@ class FluidMaxWrapper template static void deferDump(FluidMaxWrapper* x, t_symbol*, long ac, t_atom* av) { - defer(x, (method) doDump, nullptr, static_cast(ac), av); + defer_low(x, (method) doDump, nullptr, static_cast(ac), av); } template @@ -2207,7 +2207,7 @@ class FluidMaxWrapper template static void deferPrint(FluidMaxWrapper* x, t_symbol*, long, t_atom*) { - defer(x, (method) doPrint, nullptr, 0, nullptr); + defer_low(x, (method) doPrint, nullptr, 0, nullptr); } template @@ -2225,7 +2225,8 @@ class FluidMaxWrapper template static void deferRead(FluidMaxWrapper* x, t_symbol* s) { - defer(x, (method) &doRead, s, 0, nullptr); + // defer_low because we have a dialog box situation + defer_low(x, (method) &doRead, s, 0, nullptr); } template @@ -2245,9 +2246,12 @@ class FluidMaxWrapper char fullpath[MAX_PATH_CHARS]; if (s == gensym("")) - { - if (open_dialog(filename, &path, &outtype, &filetype, 1)) + { + short openResult = open_dialog(filename, &path, &outtype, &filetype, 1); + if (openResult != 0) + { return; // non-zero -> cancel + } } else { @@ -2272,7 +2276,8 @@ class FluidMaxWrapper template static void deferWrite(FluidMaxWrapper* x, t_symbol* s) { - defer(x, (method) &doWrite, s, 0, nullptr); + // defer_low because we have a dialog box situation + defer_low(x, (method) &doWrite, s, 0, nullptr); } template