QVTKWidgetPlugin destructed after ctreating a polydata

Hello,

I created the following function that should generate a polydata out of x, y, and z coordinate of points.

def createPolyData(x , y , z , maxNumPoints=1e6) :
    data = np.column_stack((x.ravel() , y.ravel() , z.ravel()))

    polyPoints = vtk.vtkPoints()
    vtkDepth = vtk.vtkDoubleArray()
    vtkCells = vtk.vtkCellArray()
    vtkPolyData = vtk.vtkPolyData()

    for k in range(size(data , 0)) :
        point = data[k]

        if polyPoints.GetNumberOfPoints() < maxNumPoints :
            pointId = polyPoints.InsertNextPoint(point[:])
            vtkDepth.InsertNextValue(point[2])
            vtkCells.InsertNextCell(1)
            vtkCells.InsertCellPoint(pointId)
            vtkCells.Modified()
            polyPoints.Modified()
            vtkDepth.Modified()
    vtkPolyData.SetPoints(polyPoints)
    vtkPolyData.SetVerts(vtkCells)
    vtkDepth.SetName('Distance')
    vtkPolyData.GetPointData().SetScalars(vtkDepth)
    vtkPolyData.GetPointData().SetActiveScalars('Distance')

    return vtkPolyData

The attached picture is obtained after rendering that polydata in vtk using the createPolyData function
pointsefd
When I try to display the same polydata in 3DSlicer I encounter the following error : QVTKWidgetPlugin destructed after getting the output polydata and, after a while, Slicer crash.

So far I have no clue how to solve this problem. Do you have any feedback?
I hope I have been able to explain clearly my problem otherwise, I will be happy to give you more details.
Thank you :pray:

Operating System: Ubuntu 20.04.3 LTS
Slicer Version : 4.13.0 r30429 / 00d2939

Updating Slicer has fixed the problem :slightly_smiling_face: