Archived:Landmarks category selector dialog leaks memory (Known Issue)
Article Metadata
Compatibility
Article
Description
The TLmkItemIdDbCombiInfo class provides methods for getting the ID of a landmark or category and the database handle to which the selected landmark or category belongs.
The client application executes methods to get the ID of a landmark and the database handle and then uses those for its internal purposes, such as for modifying the landmark attributes or for renaming the category. Note that the client takes the ownership of the returned database pointer and is responsible for deleting it.
Incorrect use of the Landmarks category selector dialog (CLmkCategorySelectorDlg) results in a memory leak whenever a category or categories are selected.
Solution
After selecting a category, the TLmkItemIdDbCombiInfo object contains a pointer to the landmarks database. The client is responsible for deleting this pointer once it is no longer needed.
#include <clmkcategoryselectordlg.h> // link against lmkcommonui.lib
#include <tlmkitemiddbcombiinfo.h>
CLmkCategorySelectorDlg* dlg = CLmkCategorySelectorDlg::NewL(EFalse);
TLmkItemIdDbCombiInfo selectedItem;
TInt ret = dlg->ExecuteLD(selectedItem);
if( ret != 0 )
{
...
// Store the pointer to CPosLandmarkDatabase and
// remember to delete it in the destructor.
// The database pointer is the same for all landmarks
// from the same database.
ilDb = selectedItem.GetLmDb();
}
See the LocationLandmarksUIRefApp SDK example application for a demonstration on using CLmkCategorySelectorDlg.


The following is an excerpt from the Landmarks UI Selector API - API Reference Guide (mk:@MSITStore:E:\Symbian\9.2\S60_3rd_FP1\S60Doc\S60_CPP_SDK_3rd_FP1_APIRefGuide.chm::/Landmarks_UI_Selector_API4.html):
"The TLmkItemIdDbCombiInfo class provides methods for getting the ID of a landmark or category and the database handle to which the selected landmark or category belongs. The client application executes these methods to get the ID of a landmark and the database handle and then uses those for its internal usage, such as for modifying the landmark attributes or for renaming the category. The client takes the ownership of the database handle which is returned. The database handle returned to the client will be the same for all landmarks from the same database."
At best this can be retained as a documentation improvement suggestion. As a bug it is busted!
ltomuta 08:19, 25 March 2008 (EET)