diff --git a/src/AdA_VizPickTool_V1.jl b/src/AdA_VizPickTool_V1.jl index 0aedf3a..61ba558 100644 --- a/src/AdA_VizPickTool_V1.jl +++ b/src/AdA_VizPickTool_V1.jl @@ -87,7 +87,7 @@ function start_AdA_Picker(;data=nothing) ############################################################ # LOAD PROFILE DATA @async begin - fn = fetch(Threads.@spawn PICK_FILE[]("")) + fn = PICK_FILE[]("") data = load(fn,"Profile") # we need to make this more foolproof, I don't think we can rely on people calling hteir profile structure Profile println(fn*" loaded") @@ -362,7 +362,7 @@ function start_AdA_Picker(;data=nothing) elseif s == "Load Picks..." # load picks from a text file, these will be modifyable @async begin - fn = fetch(Threads.@spawn PICK_FILE[]("")) + fn = PICK_FILE[]("") println(fn) @@ -410,7 +410,7 @@ function start_AdA_Picker(;data=nothing) elseif s == "Load Picks (not modifyable)..." # load the picks as point data, these will be treated in a similar way as e.g. the seismicity data @async begin - fn = fetch(Threads.@spawn PICK_FILE[]("")) + fn = PICK_FILE[]("") # test plot in ax1 #lines!(ax1, [0,100],[0,-200], color = :red,linewidth = 3) @@ -482,7 +482,7 @@ function start_AdA_Picker(;data=nothing) profile_info = (start_lonlat = data.start_lonlat, end_lonlat = data.end_lonlat) @async begin - fn_save = fetch(Threads.@spawn SAVE_FILE[]("")) # open native file dialog and choose a filename + fn_save = SAVE_FILE[]("") # open native file dialog and choose a filename filetype = split(fn_save,".")[end] # get the ending # save depending on file ending if filetype == "jld2" @@ -504,7 +504,7 @@ function start_AdA_Picker(;data=nothing) elseif s == "Save Screenshot..." # save a screen shot of the makie window @async begin - fn_screen = fetch(Threads.@spawn SAVE_FILE[]("")) + fn_screen = SAVE_FILE[]("") save(fn_screen, fig, px_per_unit = 2) println(fn_screen*" saved") end diff --git a/src/FileIO/fileIO_utils.jl b/src/FileIO/fileIO_utils.jl index dc7f12d..e2192e2 100644 --- a/src/FileIO/fileIO_utils.jl +++ b/src/FileIO/fileIO_utils.jl @@ -8,12 +8,15 @@ using JLD2 # replace them by functions that return a fixed filename (there is no user on CI) const PICK_FILE = Ref{Function}(pick_file) const SAVE_FILE = Ref{Function}(save_file) +# The dialogs are called directly, on the main thread: macOS only allows windows to be created +# on the main thread and aborts Julia otherwise (NSWindow should only be instantiated on the main +# thread!). Opening them with `Threads.@spawn` did exactly that as soon as Julia had >1 thread. # function for fileIO menu response function menu_fileIO_response(s) if s == "Load Profile..." @async begin - filename = fetch(Threads.@spawn PICK_FILE[]("")) + filename = PICK_FILE[]("") println(filename) #data = load_GMG(filename) # load the profile data, this did not work properly data = load(filename,"Profile")