Skip to content

Commit ac6da83

Browse files
committed
mv warning from finalizer to freemodel!
- that way it only covers the case of a user trying to double-free a model
1 parent d683965 commit ac6da83

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/mpb_interface.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ numvar(m::SCIPMathProgModel) = _getNumVars(m)
1919
numconstr(m::SCIPMathProgModel) = _getNumConss(m)
2020

2121
function freemodel!(m::SCIPMathProgModel)
22-
# call finalizer directly
23-
freescip(m.inner)
22+
if m.inner.ptr_model != C_NULL
23+
# call finalizer directly
24+
freescip(m.inner)
25+
else
26+
Base.warn_once("Tried to free already freed model, ignoring.")
27+
end
2428
end
2529

2630
# TODO: mapping for :SemiCont, :SemiInt

src/types.jl

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ function freescip(m::SCIPModel)
2525
if m.ptr_model != C_NULL
2626
_freeModel(m)
2727
m.ptr_model = C_NULL
28-
else
29-
Base.warn_once("Tried to free already freed model, ignoring.")
3028
end
3129
end
3230

0 commit comments

Comments
 (0)