From c58ddea80069bd3d8ea11f1fd9b5431a39189c62 Mon Sep 17 00:00:00 2001 From: Antonio Menezes Leitao Date: Thu, 23 Nov 2023 19:34:46 +0000 Subject: [PATCH] Restructured code location. Fixed render_view returned path. --- src/Backend.jl | 33 +++++++++++++++++++++++++++++++-- src/Camera.jl | 17 ----------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Backend.jl b/src/Backend.jl index 620146b..33eb1af 100644 --- a/src/Backend.jl +++ b/src/Backend.jl @@ -1234,12 +1234,41 @@ export b_render_pathname, b_render_inital_setup, b_render_final_setup, b_setup_r b_setup_render(b::Backend, kind) = kind b_render_view(b::Backend, name) = - let path = b_render_pathname(b, name) + let path = prepare_for_saving_file(b_render_pathname(b, name)) b_render_final_setup(b, render_kind()) - b_render_and_save_view(b, prepare_for_saving_file(path)) + b_render_and_save_view(b, path) path end +#= +prepare_for_saving_file(path::String) = + let p = normpath(path) + mkpath(dirname(p)) + rm(p, force=true) + isfile(p) ? # rm failed because file is locked + let (base, ext) = splitext(path) + prepare_for_saving_file(base*"_"*ext) + end : + p + end +=# +prepare_for_saving_file(path::String) = + let p = normpath(path) + mkpath(dirname(p)) + try + rm(p, force=true) + p + catch e + if isa(e, Base.IOError) + let (base, ext) = splitext(path) + if ext == ".pdf" + prepare_for_saving_file(base*"_"*ext) + end + end + end + end + end + b_render_pathname(::Backend, name::String) = render_default_pathname(name) b_render_initial_setup(::Backend, kind) = kind b_render_final_setup(::Backend, kind) = kind diff --git a/src/Camera.jl b/src/Camera.jl index fd2b188..1960aaf 100644 --- a/src/Camera.jl +++ b/src/Camera.jl @@ -53,23 +53,6 @@ render_size() = render_size(width::Integer, heigth::Integer) = (render_width(width), render_height(heigth)) -prepare_for_saving_file(path::String) = - let p = normpath(path) - mkpath(dirname(p)) - try - rm(p, force=true) - p - catch e - if isa(e, Base.IOError) - let (base, ext) = splitext(path) - if ext == ".pdf" - prepare_for_saving_file(base*"_"*ext) - end - end - end - end - end - export film_active, film_filename, film_frame,