Ignore:
Timestamp:
10/26/12 10:30:53 (18 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Clear invalid PyObject pointers stored in a global variable which outlives the python interpreter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orange/lib_kernel.cpp

    r10970 r11001  
    18811881 
    18821882 
    1883 vector<TFiletypeDefinition> filetypeDefinitions; 
     1883class GlobalFiletypeDefinitionVector: public vector<TFiletypeDefinition> 
     1884{ 
     1885public: 
     1886  ~GlobalFiletypeDefinitionVector() 
     1887  { 
     1888    /* 
     1889     * The 'filetypeDefinitions' below will be (and should be) 
     1890     * the only instance and it will outlive the Python interpreter. 
     1891     * This destructor will be called in clib's exit() and at that time the 
     1892     * 'saver' and 'loader' pointers in TFiletypeDefinition are no 
     1893     * longer valid so we set them to NULL so Py_XDECREF macro in 
     1894     * TFiletypeDefinition destructor does nothing. 
     1895     */ 
     1896    for (GlobalFiletypeDefinitionVector::iterator iter = begin(); 
     1897         iter != end(); 
     1898         iter++) 
     1899    { 
     1900      iter->loader = NULL; 
     1901      iter->saver = NULL; 
     1902    } 
     1903  } 
     1904}; 
     1905 
     1906GlobalFiletypeDefinitionVector filetypeDefinitions; 
     1907 
    18841908 
    18851909/* lower case to avoid any ambiguity problems (don't know how various compilers can react when 
Note: See TracChangeset for help on using the changeset viewer.