[GRASS-dev] [GRASS-SVN] r69248 - grass/trunk/gui/wxpython/tplot

On Wed, Aug 24, 2016 at 9:29 AM, <svn_grass@osgeo.org> wrote:

+ self.__del__()
         self.Destroy()

`self.__del__()` just doesn't sound right. A function such as
release_resources() is recommended in these cases, see e.g.:

http://stackoverflow.com/a/6104568/574907

On 24 August 2016 at 16:40, Vaclav Petras <wenzeslaus@gmail.com> wrote:

On Wed, Aug 24, 2016 at 9:29 AM, <svn_grass@osgeo.org> wrote:

+ self.__del__()
         self.Destroy()

`self.__del__()` just doesn't sound right. A function such as
release_resources() is recommended in these cases, see e.g.:

http://stackoverflow.com/a/6104568/574907

thanks Vaclav, god to know... but I think it could be correct that
function should be called before it will be destroyed

However we have __del__ function in several gui classes

animation/frame.py: def __del__(self):
core/gcmd.py: def __del__(self):
core/render.py: def __del__(self):
core/ws.py: def __del__(self):
core/ws.py: def __del__(self):
gcp/manager.py: def __del__(self):
gmodeler/model.py: def __del__(self):
gmodeler/model.py: def __del__(self):
mapwin/base.py: def __del__(self):
nviz/mapwindow.py: def __del__(self):
nviz/wxnviz.py: def __del__(self):
nviz/wxnviz.py: def __del__(self):
timeline/frame.py: def __del__(self):
tplot/frame.py: def __del__(self):
vdigit/wxdigit.py: def __del__(self):
vdigit/wxdisplay.py: def __del__(self):
vnet/vnet_core.py: def __del__(self):
vnet/vnet_data.py: def __del__(self):
vnet/vnet_data.py: def __del__(self):
vnet/vnet_data.py: def __del__(self):
web_services/dialogs.py: def __del__(self):
web_services/widgets.py: def __del__(self):

I didn't check all but for example animation/frame.py is identical to
tplot/frame.py
If we decide to rename __del__ function I could do that

--
ciao
Luca

www.lucadelu.org

On Wed, Aug 24, 2016 at 10:52 AM, Luca Delucchi <lucadeluge@gmail.com>
wrote:

thanks Vaclav, god to know... but I think it could be correct that
function should be called before it will be destroyed

__del__ in Python is complicated. I'm not sure what is the correct way to
use it. I only know that if you want to release resource, you should call
close(), free(), release(), Destroy() or whatever is the name. One doesn't
call __del__() explicitly on the object itself.

However we have __del__ function in several gui classes

I didn't check all but for example animation/frame.py is identical to
tplot/frame.py
If we decide to rename __del__ function I could do that

No, each case might be different. Although some revision might be useful,
there is no other case where object would call __del__ on itself
(`self.__del__`):

grep -Irn "self.__del__"

But what might be happening in the current code is that the resources are
not released but that requires case-by-case investigation.