On Nov 15, 2007 10:41 AM, joe ertaba <[EMAIL PROTECTED]> wrote: > ok! > My code is: > [snip code registering a nsIObserverService observer in a window] > > i have to problems: > > how can i find that observer is registered before or not ?
You're not asking the right question, see below. (There's no way to find that out, unless you keep track of your observers yourself.) > when i register observer only when first window opens every thing is ok, > when i open some other windows still every thing is ok and observer works > perfectly, but when i close first window while other windows are still open > the observer doesn't work anymore ?! > Right, the observer you registered in the first window is gone with the window (or worse, not unregistered when that window is closed and leaking memory and causing scary exceptions). What you need to do is look at the code in observer and figure out if it's window-specific (i.e. does the observer do something to the window) or not (i.e. it does something not related to any browser window). It looks like it's the latter. The correct solution in this case, as Michael wrote, is implementing an XPCOM component (which is independent of any windows) and registering the observer from the component on startup. See http://developer.mozilla.org/en/docs/How_to_Build_an_XPCOM_Component_in_Javascript You might find the example at http://forums.mozillazine.org/viewtopic.php?p=1694347#1694347 more useful, since it includes the code necessary to register a startup observer. The registration code at the bottom of the samples might look scary, but you don't need to understand it yet. If you're writing for Fx3 only, you can use XPCOMUtils.jsm instead of the long registration code. Nickolay > > > > On Nov 15, 2007 10:34 AM, Nickolay Ponomarev <[EMAIL PROTECTED]> wrote: > > > > On Nov 15, 2007 12:39 AM, joe ertaba <[EMAIL PROTECTED]> wrote: > > > hi Nickolay > > > > > > i have registered an observer , now my problem is how to find out : > > > am i already register this observer or not when user open a new window, > > > > > > in my extension observer registered when user open new window > > > > > > > > You give too few details. How about you tell what you're trying to do, > > then show the relevant snippets of code? > > > > Nickolay > > > > > > > > > > > > > On Nov 14, 2007 1:13 PM, Nickolay Ponomarev <[EMAIL PROTECTED]> wrote: > > > > On Nov 13, 2007 10:59 PM, joe ertaba < [EMAIL PROTECTED]> wrote: > > > > > i need to add a listener to my extension, the listener must be > global, > > > > > it must support all windows together? is it possible to do this with > > > > > one listener > > > > > > > > > What kind of listener? Some 'listeners' (such as global observers > > > > registered via nsIObserverService) are not window-dependent and can be > > > > registered globally from an XPCOM component. > > > > > > > > Nickolay > > > > > > > _______________________________________________ > > > > Project_owners mailing list > > > > [EMAIL PROTECTED] > > > > https://www.mozdev.org/mailman/listinfo/project_owners > > > > > > > > > > > > > _______________________________________________ > > > Project_owners mailing list > > > [email protected] > > > > > https://www.mozdev.org/mailman/listinfo/project_owners > > > > > > > > _______________________________________________ > > Project_owners mailing list > > [email protected] > > > > > > > > https://www.mozdev.org/mailman/listinfo/project_owners > > > > > _______________________________________________ > Project_owners mailing list > [email protected] > https://www.mozdev.org/mailman/listinfo/project_owners > > _______________________________________________ Project_owners mailing list [email protected] https://www.mozdev.org/mailman/listinfo/project_owners
