1

I have a TreeView connected with a ListStore object. One of the function calls ListStore.get_iter_next(). Since the ListStore data changes every time, I am doubtful that iter is causing a memory leak.

I need to check if the ListStore has gtk.TREE_MODEL_ITERS_PERSIST flag set and unset it as described in TreeModel.get_flags() documentation.

How could I do that?

Kashif
  • 1,238
  • 10
  • 15

1 Answers1

1

It would appear you would just use bitwise operations on it - for example:

>>> a = 3 # just some number
>>> format(a, 'b') # display as a bit string so we can see what's going on
'11'
>>> a & 1 # check first bit is set
1
>>> a & 2 # check second bit is set
2 
>>> a ^= 1 # unset a bit
>>> format(a, 'b') # display for checking again...
'10'

Except you would use gtk.TREE_MODEL_ITERS_PERSIST instead... whether this is the right approach to your problem - I'm not sure - but answers your direct question as to how you could unset it.

Jon Clements
  • 138,671
  • 33
  • 247
  • 280
  • What I mean is how exactly I set the flag? I am expecting something like store.set_flag(store.currentFlags ^ gtk.TREE_MODEL_ITERS_PERSIST). But I could not find such a function. – Kashif Dec 27 '12 at 11:19
  • @Kashif Ummm - it's possible you're not meant to - you could look at the attribute that `get_flags()` returns and modify it directly - but at this point - I would be thinking you're *definitely* not meant to... – Jon Clements Dec 27 '12 at 11:23
  • Documentation for `get_flags()` says it is a set of flags supported by ListStore – Kashif Dec 27 '12 at 11:26