You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Weechat buffer can be either created or searched for using the Weechat object e.g.:
let buffer: Buffer = weechat.buffer_new(None, Some(input_cb)...);
At the time of creation/search this buffer object will almost always be valid, and we can use it without any fear of it disappearing. Once we give control back to Weechat an user could close the buffer rendering our object invalid.
One way to solve this is to only give users access to a reference of the Weechat object and bind the lifetime of the Buffer to the Weechat object with a PhantomData field.
This should certainly be done for the buffers that are returned with the weechat.buffer_search() method since there is no way of knowing when the buffer gets destroyed.
For Buffers that are created by our own plugin the buffer_close callback will get called before the object will become invalid. We could let users keep the Buffer object but have them unlock it which checks if the buffer was destroyed.
The text was updated successfully, but these errors were encountered:
A Weechat buffer can be either created or searched for using the
Weechat
object e.g.:At the time of creation/search this buffer object will almost always be valid, and we can use it without any fear of it disappearing. Once we give control back to Weechat an user could close the buffer rendering our object invalid.
One way to solve this is to only give users access to a reference of the
Weechat
object and bind the lifetime of the Buffer to theWeechat
object with aPhantomData
field.This should certainly be done for the buffers that are returned with the
weechat.buffer_search()
method since there is no way of knowing when the buffer gets destroyed.For Buffers that are created by our own plugin the buffer_close callback will get called before the object will become invalid. We could let users keep the Buffer object but have them unlock it which checks if the buffer was destroyed.
The text was updated successfully, but these errors were encountered: