Skip to content

Commit

Permalink
Merge pull request #287 from GenericMappingTools/avoidsessmemissue
Browse files Browse the repository at this point in the history
Workaround the session long memory issue
  • Loading branch information
joa-quim authored Jul 15, 2019
2 parents dc234cb + c65d5f3 commit e6146ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ global current_view = nothing # To store the current viewpoint (-p)
global multi_col = false # To allow plottig multiple columns at once
global IamModern = false # To know if we are in modern mode
global IamSubplot = false # To know if we are in subplot mode
global usedConfPar = false # Hacky solution for the session's memory trouble
const FMT = "ps"
const def_fig_size = "12c/8c" # Default fig size for plot like programs
const def_fig_axes = " -Baf -BWSen" # Default fig axes for plot like programs
Expand Down
12 changes: 10 additions & 2 deletions src/common_options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ function parse_common_opts(d, cmd, opts, first=true)
end
if (opt_p !== nothing) # Restrict the contents of this block to when -p was used
if (opt_p != "")
if (opt_p == "none") current_view = nothing
else current_view = opt_p
if (opt_p == " -pnone") current_view = nothing; cmd = cmd[1:end-7]; opt_p = ""
else current_view = opt_p
end
elseif (!first && current_view !== nothing)
cmd *= current_view
Expand Down Expand Up @@ -763,6 +763,7 @@ function parse_params(cmd::String, d::Dict)
elseif (isa(val, Tuple))
cmd *= " --" * string(val[1]) * "=" * string(val[2])
end
global usedConfPar = true
end
return cmd
end
Expand Down Expand Up @@ -2127,6 +2128,7 @@ function showfig(d::Dict, fname_ps::String, fname_ext::String, opt_T::String, K=
out = mv(out, fname, force=true)
end
elseif (fname_ps != "")
if (K) gmt("psxy -T -R0/1/0/1 -JX1 -O >> " * fname_ps) end # Close the PS file first
out = fname_ps
if (fname != "")
out = mv(out, fname, force=true)
Expand Down Expand Up @@ -2177,6 +2179,7 @@ function finish_PS_module(d::Dict, cmd, opt_extra::String, output::String, fname

if ((r = dbg_print_cmd(d, cmd)) !== nothing) return r end # For tests only
global img_mem_layout = add_opt("", "", d, [:layout])
global usedConfPar

if (isa(cmd, Array{String, 1}))
for k = 1:length(cmd)
Expand All @@ -2188,6 +2191,11 @@ function finish_PS_module(d::Dict, cmd, opt_extra::String, output::String, fname

digests_legend_bag(d) # Plot the legend if requested

if (usedConfPar) # Hacky shit to force start over when --PAR options were use
usedConfPar = false
gmt("destroy")
end

fname = ""
if (haskey(d, :savefig)) # Also ensure that file has the right extension
fname, ext = splitext(d[:savefig])
Expand Down
3 changes: 2 additions & 1 deletion src/psxy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ function get_marker_name(d::Dict, symbs, is3D, del=false, arg1=nothing)
if (t == "-" || t == "x-dash") marca = "-"
elseif (t == "+" || t == "plus") marca = "+"
elseif (t == "a" || t == "*" || t == "star") marca = "a"
elseif (t == "k" || t == "custom") marca = "k"
elseif (t == "x" || t == "cross") marca = "x"
elseif (t[1] == 'c' || t[1] == 'C') marca = "c"
elseif (t == "d" || t == "diamond") marca = "d"
elseif (t == "g" || t == "octagon") marca = "g"
Expand All @@ -349,7 +351,6 @@ function get_marker_name(d::Dict, symbs, is3D, del=false, arg1=nothing)
elseif (t == "s" || t == "square") marca = "s"
elseif (t == "t" || t == "^" || t == "triangle") marca = "t"
elseif (t == "T" || t == "Triangle") marca = "T"
elseif (t == "x" || t == "cross") marca = "x"
elseif (is3D && (t == "u" || t == "cube")) marca = "u"
elseif (t == "y" || t == "y-dash") marca = "y"
end
Expand Down

0 comments on commit e6146ec

Please sign in to comment.