Salome HOME
Update pre-requisites for SALOME 7.4.0
[tools/install.git] / config_files / patches / ParaView-4.1.0.patch
1 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/CMakeLists.txt ParaView-4.1.0_SRC-new/CMakeLists.txt
2 --- ParaView-4.1.0_SRC-orig/CMakeLists.txt      2014-01-11 17:59:57.000000000 +0400
3 +++ ParaView-4.1.0_SRC-new/CMakeLists.txt       2014-05-05 12:30:42.000000000 +0400
4 @@ -511,7 +511,7 @@
5  
6    #----------------------------------------------------------------------------------
7    # Set some flags that affect VTK's modules.
8 -  set (VTK_NO_PYTHON_THREADS 1 CACHE INTERNAL
9 +  set (VTK_NO_PYTHON_THREADS OFF CACHE INTERNAL
10                                 "Disable Python Threads support" FORCE)
11    set(VTK_WRAP_PYTHON ${PARAVIEW_ENABLE_PYTHON}
12      CACHE INTERNAL "Should VTK Python wrapping be built?" FORCE)
13 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx ParaView-4.1.0_SRC-new/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx
14 --- ParaView-4.1.0_SRC-orig/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx 2014-01-11 17:59:57.000000000 +0400
15 +++ ParaView-4.1.0_SRC-new/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxx  2014-05-05 12:30:57.000000000 +0400
16 @@ -276,7 +276,7 @@
17  {
18    if (!info)
19      {
20 -    vtkWarningMacro("Could not determine array range.");
21 +    // vtkWarningMacro("Could not determine array range.");
22      return false;
23      }
24  
25 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h ParaView-4.1.0_SRC-new/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h
26 --- ParaView-4.1.0_SRC-orig/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h       2014-01-11 17:59:57.000000000 +0400
27 +++ ParaView-4.1.0_SRC-new/ParaViewCore/VTKExtensions/Default/vtkPVImageReader.h        2014-05-05 12:30:42.000000000 +0400
28 @@ -19,27 +19,15 @@
29  
30  #include "vtkPVVTKExtensionsDefaultModule.h" //needed for exports
31  
32 -#ifdef PARAVIEW_USE_MPI
33 -#include "vtkMPIImageReader.h"
34 -#else
35  #include "vtkImageReader.h"
36 -#endif
37  
38 -class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkPVImageReader : public
39 -#ifdef PARAVIEW_USE_MPI
40 -vtkMPIImageReader
41 -#else
42 -vtkImageReader
43 -#endif
44 +class VTKPVVTKEXTENSIONSDEFAULT_EXPORT vtkPVImageReader : public vtkImageReader
45  {
46  public:
47    static vtkPVImageReader* New();
48  
49 -#ifdef PARAVIEW_USE_MPI
50 -  vtkTypeMacro(vtkPVImageReader, vtkMPIImageReader);
51 -#else
52 +
53    vtkTypeMacro(vtkPVImageReader, vtkImageReader);
54 -#endif
55  
56    void PrintSelf(ostream& os, vtkIndent indent);
57  
58 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/Qt/Python/pqPythonManager.cxx ParaView-4.1.0_SRC-new/Qt/Python/pqPythonManager.cxx
59 --- ParaView-4.1.0_SRC-orig/Qt/Python/pqPythonManager.cxx       2014-01-11 18:00:00.000000000 +0400
60 +++ ParaView-4.1.0_SRC-new/Qt/Python/pqPythonManager.cxx        2014-05-05 12:30:42.000000000 +0400
61 @@ -139,7 +139,7 @@
62    // initialized (by a startup plugin, for example)
63    if (vtkPythonInterpreter::IsInitialized())
64      {
65 -    importParaViewModule();
66 +    //importParaViewModule();
67      }
68    }
69    ~pqInternal()
70 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Common/Core/vtkCharArray.h ParaView-4.1.0_SRC-new/VTK/Common/Core/vtkCharArray.h
71 --- ParaView-4.1.0_SRC-orig/VTK/Common/Core/vtkCharArray.h      2014-01-11 18:02:05.000000000 +0400
72 +++ ParaView-4.1.0_SRC-new/VTK/Common/Core/vtkCharArray.h       2014-05-05 12:30:42.000000000 +0400
73 @@ -48,7 +48,26 @@
74    // make up the interface of vtkDataArrayTemplate, which is ignored
75    // by the wrappers.
76  #ifdef __WRAP__
77 -  vtkCreateWrappedArrayInterface(char);
78 +//  vtkCreateWrappedArrayInterface(char);
79 +
80 +  // [ABN] manual macro expansion to avoid the last 4 methods (they were BTX/ETX enclosed in
81 +  // prev versions of PV, meaning not included in the wrapping).
82 +  int GetDataType();
83 +  void GetTupleValue(vtkIdType i, char* tuple);
84 +  void SetTupleValue(vtkIdType i, const char* tuple);
85 +  void InsertTupleValue(vtkIdType i, const char* tuple);
86 +  vtkIdType InsertNextTupleValue(const char* tuple);
87 +  char GetValue(vtkIdType id);
88 +  void SetValue(vtkIdType id, char value);
89 +  void SetNumberOfValues(vtkIdType number);
90 +  void InsertValue(vtkIdType id, char f);
91 +  vtkIdType InsertNextValue(char f);
92 +
93 +//  T *GetValueRange(int comp);
94 +//  T *GetValueRange();
95 +//  T* WritePointer(vtkIdType id, vtkIdType number);
96 +//  T* GetPointer(vtkIdType id);
97 +
98  #endif
99  
100    // Description:
101 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx ParaView-4.1.0_SRC-new/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx
102 --- ParaView-4.1.0_SRC-orig/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx 2014-01-11 18:02:10.000000000 +0400
103 +++ ParaView-4.1.0_SRC-new/VTK/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx  2014-05-05 12:30:42.000000000 +0400
104 @@ -74,7 +74,7 @@
105  //----------------------------------------------------------------------------
106  vtkMatplotlibMathTextUtilities::Availablity
107  vtkMatplotlibMathTextUtilities::MPLMathTextAvailable =
108 -vtkMatplotlibMathTextUtilities::NOT_TESTED;
109 +vtkMatplotlibMathTextUtilities::UNAVAILABLE;
110  
111  // A macro that is used in New() to print warnings if VTK_MATPLOTLIB_DEBUG
112  // is defined in the environment. Use vtkGenericWarningMacro to allow this to
113 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/Python/vtkPython.h ParaView-4.1.0_SRC-new/VTK/Utilities/Python/vtkPython.h
114 --- ParaView-4.1.0_SRC-orig/VTK/Utilities/Python/vtkPython.h    2014-01-11 18:02:13.000000000 +0400
115 +++ ParaView-4.1.0_SRC-new/VTK/Utilities/Python/vtkPython.h     2014-05-05 12:30:42.000000000 +0400
116 @@ -87,4 +87,14 @@
117  #error "Python.h is different version from what VTK was configured with!!"
118  #endif
119  
120 +#ifdef VTK_NO_PYTHON_THREADS
121 +#  define VTK_PY_GIL_ENSURE
122 +#  define VTK_PY_GIL_RELEASE
123 +#else
124 +#  define VTK_PY_GIL_ENSURE  PyGILState_STATE _gstate_avoid_clash = PyGILState_Ensure();
125 +#  define VTK_PY_GIL_RELEASE PyGILState_Release(_gstate_avoid_clash);
126 +#
127 +#endif
128 +
129 +
130  #endif
131 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx
132 --- ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx 2014-01-11 18:02:13.000000000 +0400
133 +++ ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInteractiveInterpreter.cxx  2014-05-05 12:30:42.000000000 +0400
134 @@ -45,6 +45,7 @@
135  
136    void CleanupPythonObjects()
137      {
138 +    VTK_PY_GIL_ENSURE
139      Py_XDECREF(this->InteractiveConsoleLocals);
140      Py_XDECREF(this->InteractiveConsole);
141      this->InteractiveConsole = NULL;
142 @@ -54,6 +55,7 @@
143        const char* code = "import gc; gc.collect()\n";
144        vtkPythonInterpreter::RunSimpleString(code);
145        }
146 +    VTK_PY_GIL_RELEASE
147      }
148  
149    PyObject* GetInteractiveConsole()
150 @@ -65,6 +67,7 @@
151  
152      vtkPythonInterpreter::Initialize();
153  
154 +    VTK_PY_GIL_ENSURE
155      // set up the code.InteractiveConsole instance that we'll use.
156      const char* code = "import code\n"
157        "__vtkConsoleLocals={'__name__':'__vtkconsole__','__doc__':None}\n"
158 @@ -83,6 +86,7 @@
159        {
160        vtkGenericWarningMacro(
161          "Failed to locate the InteractiveConsole/InteractiveConsoleLocals object.");
162 +      VTK_PY_GIL_RELEASE
163        return NULL;
164        }
165      Py_INCREF(this->InteractiveConsole);
166 @@ -105,7 +109,7 @@
167        PySys_SetObject(const_cast<char*>("ps2"), ps2 = PyString_FromString("... "));
168        Py_XDECREF(ps2);
169        }
170 -
171 +    VTK_PY_GIL_RELEASE
172      return this->InteractiveConsole;
173      }
174  };
175 @@ -167,6 +171,7 @@
176      i++;
177      }
178  
179 +  VTK_PY_GIL_ENSURE
180    bool ret_value = false;
181    PyObject *res = PyObject_CallMethod(console,
182      const_cast<char*>("push"), const_cast<char*>("z"), buffer.c_str());
183 @@ -179,6 +184,7 @@
184        }
185      Py_DECREF(res);
186      }
187 +  VTK_PY_GIL_RELEASE
188    return ret_value;
189  }
190  
191 @@ -190,12 +196,14 @@
192  
193    this->Internals->GetInteractiveConsole(); //ensure the console is initialized
194  
195 +  VTK_PY_GIL_ENSURE
196    PyObject* context = this->Internals->GetInteractiveConsoleLocalsPyObject();
197    PyObject* result = PyRun_String(const_cast<char*>(script), Py_file_input, context, context);
198  
199    if (result == NULL)
200      {
201      PyErr_Print();
202 +    VTK_PY_GIL_RELEASE
203      return -1;
204      }
205  
206 @@ -204,6 +212,7 @@
207      {
208      PyErr_Clear();
209      }
210 +  VTK_PY_GIL_RELEASE
211    return 0;
212  }
213  
214 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx
215 --- ParaView-4.1.0_SRC-orig/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx    2014-01-11 18:02:13.000000000 +0400
216 +++ ParaView-4.1.0_SRC-new/VTK/Utilities/PythonInterpreter/vtkPythonInterpreter.cxx     2014-05-05 12:30:42.000000000 +0400
217 @@ -60,10 +60,12 @@
218  
219    inline void vtkPrependPythonPath(const char* pathtoadd)
220      {
221 +    VTK_PY_GIL_ENSURE
222      PyObject* path = PySys_GetObject(const_cast<char*>("path"));
223      PyObject* newpath = PyString_FromString(pathtoadd);
224      PyList_Insert(path, 0, newpath);
225      Py_DECREF(newpath);
226 +    VTK_PY_GIL_RELEASE
227      }
228  }
229  
230 @@ -107,7 +109,6 @@
231  //----------------------------------------------------------------------------
232  bool vtkPythonInterpreter::Initialize(int initsigs /*=0*/)
233  {
234 -  vtkPythonInterpreter::InitializedOnce = true;
235    if (Py_IsInitialized() == 0)
236      {
237  #if (VTK_PYTHON_MAJOR_VERSION > 2) ||\
238 @@ -117,11 +118,24 @@
239      (void)initsigs;
240      Py_Initialize();
241  #endif
242 -
243  #ifdef SIGINT
244      // Put default SIGINT handler back after Py_Initialize/Py_InitializeEx.
245      signal(SIGINT, SIG_DFL);
246  #endif
247 +    }
248 +
249 +  if (! vtkPythonInterpreter::InitializedOnce)
250 +    {
251 +#ifndef VTK_NO_PYTHON_THREADS
252 +    PyEval_InitThreads(); // safe to call this multiple time
253 +#endif
254 +    // At this point we have GIL, or we are mono-thread.
255 +    // Access to the static below is safe:
256 +    vtkPythonInterpreter::InitializedOnce = true;
257 +
258 +#ifndef VTK_NO_PYTHON_THREADS
259 +    PyEval_ReleaseLock();  // release GIL
260 +#endif
261      // HACK: Calling PyRun_SimpleString for the first time for some reason results in
262      // a "\n" message being generated which is causing the error dialog to
263      // popup. So we flush that message out of the system before setting up the
264 @@ -134,15 +148,17 @@
265      vtkPythonStdStreamCaptureHelper* wrapperErr =
266        NewPythonStdStreamCaptureHelper(true);
267  
268 -    // Redirect Python's stdout and stderr and stdin
269 -    PySys_SetObject(const_cast<char*>("stdout"),
270 +    // Redirect Python's stdout and stderr and stdin - GIL protected operation
271 +    VTK_PY_GIL_ENSURE
272 +    int ret1 = PySys_SetObject(const_cast<char*>("stdout"),
273        reinterpret_cast<PyObject*>(wrapperOut));
274 -    PySys_SetObject(const_cast<char*>("stderr"),
275 +    int ret2 = PySys_SetObject(const_cast<char*>("stderr"),
276        reinterpret_cast<PyObject*>(wrapperErr));
277 -    PySys_SetObject(const_cast<char*>("stdin"),
278 +    int ret3 = PySys_SetObject(const_cast<char*>("stdin"),
279        reinterpret_cast<PyObject*>(wrapperOut));
280      Py_DECREF(wrapperOut);
281      Py_DECREF(wrapperErr);
282 +    VTK_PY_GIL_RELEASE
283  
284      for (size_t cc=0; cc < PythonPaths.size(); cc++)
285        {
286 @@ -213,6 +229,7 @@
287  }
288  
289  //----------------------------------------------------------------------------
290 +// [ABN] not thread safe for now - only used by pvpython?
291  int vtkPythonInterpreter::PyMain(int argc, char** argv)
292  {
293    if (!vtkPythonInterpreter::InitializedOnce && Py_IsInitialized() == 0 &&
294 @@ -235,7 +252,9 @@
295    buffer.erase(std::remove(buffer.begin(), buffer.end(), '\r'), buffer.end());
296  
297    // The cast is necessary because PyRun_SimpleString() hasn't always been const-correct
298 +  VTK_PY_GIL_ENSURE
299    PyRun_SimpleString(const_cast<char*>(buffer.c_str()));
300 +  VTK_PY_GIL_RELEASE
301  }
302  
303  //----------------------------------------------------------------------------
304 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx ParaView-4.1.0_SRC-new/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx
305 --- ParaView-4.1.0_SRC-orig/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx        2014-01-11 18:02:14.000000000 +0400
306 +++ ParaView-4.1.0_SRC-new/VTK/Wrapping/PythonCore/vtkPythonCommand.cxx 2014-05-05 12:30:42.000000000 +0400
307 @@ -30,14 +30,18 @@
308    vtkPythonUtil::UnRegisterPythonCommand(this);
309    if (this->obj && Py_IsInitialized())
310      {
311 +    VTK_PY_GIL_ENSURE
312      Py_DECREF(this->obj);
313 +    VTK_PY_GIL_RELEASE
314      }
315    this->obj = NULL;
316  }
317  
318  void vtkPythonCommand::SetObject(PyObject *o)
319  {
320 +  VTK_PY_GIL_ENSURE
321    Py_INCREF(o);
322 +  VTK_PY_GIL_RELEASE
323    this->obj = o;
324  }
325  
326 @@ -75,11 +79,11 @@
327    // If a threadstate has been set using vtkPythonCommand::SetThreadState,
328    // then swap it in here.  See the email to vtk-developers@vtk.org from
329    // June 18, 2009 with subject "Py_NewInterpreter and vtkPythonCallback issue"
330 -  PyThreadState* prevThreadState = NULL;
331 -  if (this->ThreadState)
332 -    {
333 -    prevThreadState = PyThreadState_Swap(this->ThreadState);
334 -    }
335 +//  PyThreadState* prevThreadState = NULL;
336 +//  if (this->ThreadState)
337 +//    {
338 +//    prevThreadState = PyThreadState_Swap(this->ThreadState);
339 +//    }
340  
341    if (ptr && ptr->GetReferenceCount() > 0)
342      {
343 @@ -176,10 +180,10 @@
344      }
345  
346    // If we did the swap near the top of this function then swap back now.
347 -  if (this->ThreadState)
348 -    {
349 -    PyThreadState_Swap(prevThreadState);
350 -    }
351 +//  if (this->ThreadState)
352 +//    {
353 +//    PyThreadState_Swap(prevThreadState);
354 +//    }
355  
356  #ifndef VTK_NO_PYTHON_THREADS
357  #if (PY_MAJOR_VERSION > 2) || \
358 diff -Naur --exclude=CVS ParaView-4.1.0_SRC-orig/Wrapping/Python/paraview/servermanager.py ParaView-4.1.0_SRC-new/Wrapping/Python/paraview/servermanager.py
359 --- ParaView-4.1.0_SRC-orig/Wrapping/Python/paraview/servermanager.py   2014-01-11 18:00:00.000000000 +0400
360 +++ ParaView-4.1.0_SRC-new/Wrapping/Python/paraview/servermanager.py    2014-05-05 12:30:57.000000000 +0400
361 @@ -1095,7 +1095,7 @@
362          property = self.SMProperty
363          nElems = property.GetNumberOfElements()
364          if nElems%2 != 0:
365 -            raise ValueError, "The SMProperty with XML label '%s' has a size that is not a multiple of 2." % property.GetXMLLabel()
366 +            nElems -= 1
367          self.__arrays = []
368          for i in range(0, nElems, 2):
369              if self.GetElement(i+1) != '0':