|
15 | 15 | ##You should have received a copy of the GNU Lesser General Public License
|
16 | 16 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
|
17 | 17 |
|
18 |
| -# Init logging system |
19 |
| -from collections import deque |
| 18 | +import warnings |
| 19 | +warnings.warn("Deprecation Warning: do not use the GarbageCollector anymore, it is unneeded.") |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class GarbageCollector(object):
|
23 |
| - """ Garbage collector for OCC objects |
| 23 | + """ DEPRECATED. Garbage collector for OCC objects |
24 | 24 | """
|
25 | 25 | def __init__(self):
|
26 |
| - #self._collected_objects = [] |
27 |
| - self._handles = deque() |
28 |
| - self._transients = deque() |
29 |
| - self._misc = deque() |
30 |
| - |
31 |
| - # The list for the prevented objects |
32 |
| - self._prevent = deque() |
33 |
| - |
34 |
| - # define contexts lists |
35 |
| - self._handles_contexts = deque() |
36 |
| - self._transients_contexts = deque |
37 |
| - self._misc_contexts = deque() |
| 26 | + pass |
38 | 27 |
|
39 | 28 | def prevent_object(self, obj):
|
40 |
| - ''' Prevent an object from being deleted. This object is temporary |
| 29 | + ''' DEPRECATED. Prevent an object from being deleted. This object is temporary |
41 | 30 | stored in a list to increase its refecount.
|
42 | 31 | '''
|
43 |
| - self._prevent.append(obj) |
| 32 | + pass |
44 | 33 |
|
45 | 34 | def push_context(self):
|
46 |
| - ''' Create a new context. When the push context method is called, |
| 35 | + ''' DEPRECATED. Create a new context. When the push context method is called, |
47 | 36 | objects are collected in this new context. When the context is popped,
|
48 | 37 | erase the content of the context.
|
49 | 38 | '''
|
50 |
| - # store the current objects in the contexts list |
51 |
| - self._handles_contexts.append(self._handles) |
52 |
| - self._transients_contexts.append(self._transients) |
53 |
| - self._misc_contexts.append(self._misc) |
54 |
| - # Then erase the content of the current lists |
55 |
| - self._handles = deque() |
56 |
| - self._transients = deque() |
57 |
| - self._misc = deque() |
| 39 | + pass |
58 | 40 |
|
59 | 41 | def pop_context(self):
|
60 |
| - self._handles = self._handles_contexts.pop() |
61 |
| - self._transients = self._transients_contexts.pop() |
62 |
| - self._misc = self._misc_contexts.pop() |
| 42 | + pass |
63 | 43 |
|
64 | 44 | def collect_object(self, obj_deleted):
|
65 |
| - ''' This method is called whenever a pythonOCC instance is deleted.''' |
66 |
| - if hasattr(obj_deleted, 'was_purged'): |
67 |
| - return False |
68 |
| - if obj_deleted.__class__.__name__.startswith('Handle'): |
69 |
| - self._handles.append(obj_deleted) |
70 |
| - elif hasattr(obj_deleted, "GetHandle"): |
71 |
| - self._transients.append(obj_deleted) |
72 |
| - else: |
73 |
| - self._misc.append(obj_deleted) |
| 45 | + ''' DEPRECATED. This method is called whenever a pythonOCC instance is deleted.''' |
| 46 | + pass |
74 | 47 |
|
75 | 48 | def smart_purge(self):
|
76 |
| - # TODO: need to reverse the lists first in order |
77 |
| - # to start with the olders objects? |
78 |
| - # Remove Handles |
79 |
| - while len(self._handles) > 0: |
80 |
| - handle = self._handles.pop() |
81 |
| - handle.Nullify() # decrement ref counting_kill_pointed() |
82 |
| - # after that, the reference counting of transients objects |
83 |
| - # in the garbage should be 0 |
84 |
| - handle.was_purged = True |
85 |
| - # Remove Transients |
86 |
| - for transient in list(self._transients): |
87 |
| - transient_must_be_purged = False |
88 |
| - if transient.GetRefCount() == 0: |
89 |
| - transient_must_be_purged = True |
90 |
| - if transient_must_be_purged: |
91 |
| - #transient._kill_pointed() |
92 |
| - transient.was_purged = True |
93 |
| - self._transients.remove(transient) |
94 |
| - # Remove other objects |
95 |
| - while len(self._misc) > 0: |
96 |
| - misc = self._misc.pop() |
97 |
| - misc._kill_pointed() |
98 |
| - misc.was_purged = True |
| 49 | + # DEPRECATED. |
| 50 | + pass |
99 | 51 |
|
100 | 52 | garbage = GarbageCollector()
|
0 commit comments