But what about oneMorePtr? In this instance, it is never released; if you remember, an object cannot be released from memory until our refcount is at zero. The refcount is out of sync, oneMorePtr is never decremented before the return, and the object is thus left dangling in memory. With the refcount off, the object leaks. The correct code is shown below: if! After all references are properly released, delete is called and the object is freed from memory.

Author:Kazirg Voodoobar
Language:English (Spanish)
Published (Last):16 April 2006
PDF File Size:12.93 Mb
ePub File Size:10.96 Mb
Price:Free* [*Free Regsitration Required]

Download The complete source code for this tutorial can be downloaded from here. You can choose a different Mozilla release if you like. Extract the SDK to a local directory. Create a GUID for your main interface.

On Windows you can use the guidgen utility. On Linux you can use the uuidgen utility. Create the interface definition file - IMyComponent. Fill in the GUID you have generated. Use the xpidl utility that comes with Gecko SDK. The interface header file IMyComponent. You can copy and paste the templates to create these files, changing only your component name.

Create your component header file - MyComponent. Add include "IMyComponent. Create a GUID for your component. Create your component implementation file - MyComponent.

Add include "MyComponent. Copy the implementation template from IMyComponent. Add method implementation code. Create your module definitions file - MyComponentModule. Add include "nsIGenericFactory. You can use the templates provided with this sample to create your custom makefile.

Building the sample Download the sample code from here. Extract the sample to a local directory. Edit the makefile. The makefile is located in the src directory of the sample. It is named Makefile for Linux, MyComponent.

Choose Settings For: All Configurations in the upper left corner. Open the Link tab and choose Input in the Category drop-down list. Build the sample. Open a command shell cmd on Windows; tcsh, bash, xterm etc. Navigate to the sample src directory.

On Linux issue a make command. Copy MyComponent. Run the regxpcom command supplied with the Gecko SDK to register the new component. Delete the xpti. These files will be automatically rebuilt by Mozilla the next time it is restarted. Added: Alternatively you can "touch" either create or update a file called. Test the new component. Open the MyComponentTest. Links and Resources.


Creating XPCOM components

In fact, virtually all of the functionality that you associate with a browser - navigation, window management, managing cookies, bookmarks, security, searching, rendering, and other features - is defined in XPCOM components and accessed by means of those component interfaces. Cookie Manager Cookie management is one of the many sets of functionality that is made available to the browser in the form of an XPCOM component and that can be reused by developers who want similar functionality in their applications. Whenever a user accesses the Cookie Manager dialog to view, organize, or remove cookies that have been stored on the system, they are using the CookieManager component behind the scenes. The Cookie Manager Dialog shows user interface [cookie-manager-ui] that is presented to the user in Mozilla for working with the CookieManager component. The functionality of the CookieManager component is available through the nsICookieManager interface, which is comprised of the public methods in the table below. The interfaces are public, in other words, and the implementations are private [private-xpcom-interfaces].


Using XPCOM Components






Related Articles