Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, August 29, 2006 6:26:37 AM(UTC)

Slager  
Slager

Groups: Registered
Posts: 8


[ Lead version 14.5 ]
[ c++ using ltWrappr]


Hi, I have a question using the LAnnContainer

When I want to insert a Lannotation into a LAnnContainer,
The Lannotation object inside the LAnnContainer will be destroyed when the destructor from my Lannotation obj is called.

- A solution could be, to construct them in the heap and keep a pointer for each Lannotation object during the life cycle of a LAnnContainer. (Else the debugger detects memory leaks)

Disadvantage:
The administration of all Lannotation objects gets complicated when working with more containers in a project, coping inserting deleting etc.


- Another solution could be, inserting the obj in a TempLAnnContainer and save this container to memory: TempLAnnContainer.SaveMemory(…)
And loading in a second TempLAnnContainer2:
TempLAnnContainer2.LoadMemory(…)
Inserting the TempLAnnContainer2 in the LAnnContainer will do the job, without administration of Lannotation objects.
Disadvantage:
The SaveMemory() function sometimes gives “an Access violation” for the moment it is hard to make a condition where it will appear reproducible.

I don’t like both constructions at all, in my opinion there should be a more simple way. But I couldn’t find a solution jet.
So my question is, is there one or should I make a feature request.

Slager

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, August 31, 2006 1:06:10 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

Instead of using a separate LAnnotation class for each annotation object, use only one LAnnotation class to handle different annotation objects and insert them into the container. Keep this class alive for the duration of your program, and since it's only one class, maintaining it should be easy.

You can change the annotation objects in this LAnnotation class using LAnnotation::SetHandle or LAnnotation::Copy (to copy from a temporary LAnnotation).

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Thursday, August 31, 2006 5:28:17 AM(UTC)

Slager  
Slager

Groups: Registered
Posts: 8


Maen,

Thanks for your response,
I tried your suggestion, in my case I kept one LAnnotation member in my class, but every time I call the LAnnotation::Copy( ) function, it removes the previous Annotation, from the container.
I attached a small project to show you:
Draw lines in the red window, they will be copied to the green window.

Regards,

Slager
File Attachment(s):
Annotation.zip (9kb) downloaded 29 time(s).
 
#4 Posted : Sunday, September 3, 2006 3:36:09 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

I checked your code and resolved the problem. You need to remove the connection between the Annotation object and the wrapping class by setting the m_Annotation.SetHandle to 0 before calling the m_Annotation.Copy.
The code as follows:
+------------------+
//-------------------------------------------------------------
void CAnnotationDerivedWindow::InsertObject( LAnnotation& LAnnObject )
//-------------------------------------------------------------
{
   m_bHandleAnnEvent = false;

   m_Annotation.SetHandle(0);
   m_Annotation.Copy( LAnnObject );
   LAnnotationWindow::GetContainerObject( ).Insert( m_Annotation );
   
   m_bHandleAnnEvent = true;
}
+------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Sunday, September 3, 2006 9:48:40 PM(UTC)

Slager  
Slager

Groups: Registered
Posts: 8


Thanks,

This works, and makes my design a lot easier!!.

Slager
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.235 seconds.