Salome HOME
Merge branch 'V7_dev'
[modules/paravis.git] / test / standalone / simple / simple_gil.cxx
1 // Copyright (C) 2010-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Adrien Bruneton (CEA)
20 //
21 #include <Python.h>
22 #include <pqPVApplicationCore.h>
23 #include <QApplication>
24 #include "PyInterp_Utils.h"
25 #include "Container_init_python.hxx"
26
27 #include <iostream>
28
29 int main(int argc, char ** argv)
30 {
31   // Initialize Python in the way SALOME does:
32   KERNEL_PYTHON::init_python(argc,argv);
33
34   // The below should always work (illustration of SALOME lock protection)
35   {
36     PyLockWrapper lock;  // if commented, the below will crash:
37
38     // Nothing important, just a bunch of calls to some Py* functions!
39     PyRun_SimpleString("import base64");
40     PyObject * sysmod = PyImport_AddModule("sys");
41     PyObject* sysdict = PyModule_GetDict(sysmod);
42     PyObject* tmp = PyDict_GetItemString(sysdict, "modules");
43   }
44   std::cout << "Done with Py call" << std::endl;
45
46   // Now the Qt part:
47   QApplication qtapp(argc, argv);
48   std::cout << "Done with Qt init" << std::endl;
49
50   // And finally the ParaView part:
51   pqPVApplicationCore* myCoreApp = new pqPVApplicationCore (argc, argv);
52   std::cout << "Done with PV init" << std::endl;
53   // Make sure compilation of ParaView was made with Python support:
54   if (!myCoreApp->pythonManager())
55     return -1;
56   delete myCoreApp;
57
58   std::cout << "Done with PV deletion" << std::endl;
59
60   return 0;
61 }