Re: Privacy extension



On Fri, 2007-01-05 at 01:59 -0500, Diego Escalante wrote:
> What about catching the delete event or destroy event of the
> EphyWindow (and use the counter at the same time)?
> 
> On 1/4/07, Adam Hooper <adamh densi com> wrote:
> > On Fri, 2007-01-05 at 00:31 +0100, Jaime Frutos Morales wrote:

> > > Anybody aware of the limitations of the Extension Manager can help
> > > me,please?
> >
> > There's no "shutting down" signal, so you'll have to use attach_window
> > and detach_window with a global variable to track the number of windows
> > open. When that number hits 0 (in detach_window), you should call your
> > special "delete-stuff" code. (Note: this has the unfortunate bug that
> > unloading your extension will also trigger the "delete-stuff" code. I
> > can't, in 2 minutes, think of a trivial solution to that.)

(Next time, please don't top-post: it makes for confusing
conversations :).)

Putting a weak_ref() on each EphyWindow from an extension is an idea
which has merit: the notify is called in between ephy_window_dispose()
and ephy_window_finalize() so the Python GC is still run at the
appropriate time (in finalize()); and the callback doesn't need to
access any properties of the EphyWindow so it will run fine.

But the notify callback gets called *after* detach_window. So within
detach_window, the extension has no means to know whether Epiphany is
closing (in which case the count should be decremented) or whether it is
simply being unloaded (in which case the count should not decrement). By
contrast, the GWeakNotify callback runs either when the EphyWindow is
closing (in which case the count should be decremented) or... when the
EphyWindow is closing, *after* the extension was unloaded by the user
(in which case the GWeakNotify callback will no longer be loaded in
memory, so Epiphany will most likely crash when it tries to execute the
callback)!

Also, the Epiphany documentation makes no promise as to what extensions
should expect from EphyWindows' weak_ref callbacks. While the behaviour
hasn't changed in years, that's no guarantee that it won't change in the
future.

What we really need is a way for extensions to differentiate between
when they're being unloaded and when Epiphany is shutting down. While I
suspect such a method *may* exist in Epiphany currently, it would be
very complex. weak_ref may in fact hold the answer, but at first glance
I'm guessing that it doesn't.

Adam




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]