doc: revisions to sources/guide.lang.rst

This commit is contained in:
Zen-CODE 2014-01-28 09:40:20 +02:00
parent 4281343325
commit 755e1c418d
1 changed files with 8 additions and 7 deletions

View File

@ -252,17 +252,18 @@ garbage collected. To demonstrate:
id: label_widget id: label_widget
text: 'widget' text: 'widget'
although a reference to ``label_widget`` is stored in ``MyWidget``, it is not Although a reference to ``label_widget`` is stored in ``MyWidget``, it is not
sufficient to keep the object alive once other references are removed because it's sufficient to keep the object alive once other references have been removed
only a weakref. Therefore, after the remove button is clicked, which removes because it's only a weakref.
any direct reference to the widget, and the window resized, which calls the Therefore, after the remove button is clicked (which removes
garbage collector resulting in the deletion of ``label_widget``, when the add any direct reference to the widget) and the window is resized (which calls the
button is clicked to add back the widget a ``ReferenceError: weakly-referenced garbage collector resulting in the deletion of ``label_widget``), when the add
button is clicked to add the widget back, a ``ReferenceError: weakly-referenced
object no longer exists`` will be thrown. object no longer exists`` will be thrown.
To keep the widget alive, a direct reference to the ``label_widget`` widget To keep the widget alive, a direct reference to the ``label_widget`` widget
must be kept. This is achieved using ``id.__self__`` or ``label_widget.__self__`` must be kept. This is achieved using ``id.__self__`` or ``label_widget.__self__``
in this case. So the correct way is: in this case. The correct way to do this would be:
.. code-block:: kv .. code-block:: kv