brainvisa / anatomist-free

3D visualization of neuroimaging objects, C++ part
Other
2 stars 0 forks source link

Anatomist python bindings regression to create windows block #11

Closed nsouedet closed 4 years ago

nsouedet commented 5 years ago

The issue can be reproduced using the following python code:

from __future__ import print_function

import sys, os

from soma.qt_gui import qt_backend
qt_backend.set_qt_backend(compatible_qt5=True)
from soma.qt_gui.qt_backend import QtCore, QtGui
if not hasattr(QtCore, 'Slot'):
    QtCore.Slot = QtCore.pyqtSlot  # compatibility with PySide
qt = QtGui

import six

if sys.version_info[0] >= 3:
    unicode = str

from brainvisa.processes import *
from brainvisa import anatomist

if qt.qApp.startingUp():
    qapp = qt.QApplication(args)
    runqt = True
else:
    runqt = False

qt.qApp.processEvents()

__ims = sys.argv[1:]
win_type = 'Axial'
cols = 2
a = anatomist.Anatomist()
block = a.createWindowsBlock(cols)
objs =[]
wins =[]
for vol in __ims:
    print('loading file:', vol)
    objs.append(a.loadObject(vol))
    # The following line causes the bug. If you remove block=block, it is ok.
    win_cur = a.createWindow(win_type, block=block, no_decoration=True)
    wins.append(win_cur)
    a.addObjects(objs[len(objs)-1], wins[len(wins)-1])

a.execute('WindowConfig', windows=wins, show_toolbars='hides')

qt.qApp.processEvents()

!!! You will have to give at least 1 image as an argument to the python program !!!

denisri commented 5 years ago

In the line "a.execute('WindowConfig'...", show_toolbars='hides' should be replaced with show_toolbars=0 (int value). Well this is not the important thing... This script runs correctly for me until we exit the app (end of the script, or leave ipython if use from ipython). Then it hangs when using the bug_fix/master branch and build, and segfaults when using the trunk/integration branch. Is that what you experience ? Both hang and segfault seem to happen in the global objects destructors (two different places). But I suspect this is not really the problem you came through because it does not change when I remove the block, so it's not related to it.

ylep commented 4 years ago

Is this still an issue @nsouedet ?

nsouedet commented 4 years ago

I checked it today and it seems to work now, so I close the issue