Skip to main content
Known Participant
February 7, 2008
Question

TreeViewWidgetMgr - ApplyDataToWidget - Setting widget state

  • February 7, 2008
  • 3 replies
  • 543 views
Hi list,

I have a TreeView with a custom node and custom widgets(checkbox and static text) in that node.
I want to change the state of the checkbox and set it enabled or disabled based on some criteria.

I do this in CTreeViewWidgetMgr in the ApplyDataToWidget routine but have regular crashes.
My question is: is this the right place to do this or do i need to change widget states in another place?

Thanks a lot in advance!
Florian.
This topic has been closed for replies.

3 replies

Inspiring
February 8, 2008
It is not IDocument that you shouldn't release, but an interface returned by a Get method. This returning you InDesign's reference to the IDocument without adding a reference - when you release it you are releasing InDesign's memory and it crashes. The standard is that a Get method is just a pointer that you use, while a Query needs a Release. This is in the doc's somewhere, but I never can remember where or find it quickly to refer others to it ;-)

Ian
Known Participant
February 7, 2008
Hi Dirk,

there was indeed a memory problem.
I used an InterfacePtr to IDocument by calling IActiveContext::GetContextDocument.
Changing this to IDocument* doc = IActiveContext::GetContextDocument works fine!

While we are on this, why does ID crash if i release my IDocument? Should i not call Release() on IDocument?

Thanks,
Florian.
Inspiring
February 7, 2008
Could it be that you have the opposite of a boss leak?

Set breakpoints on a few of your destructors and verify that the objects are not disposed / freed while they should still be in use. Then check your source for balance with InterfacePtrs, AddRef and so forth.

In such cases I use a little utility that walks all interfaces and dumps the reference counter. See HelperInterface.h with ID_IINTERFACEREFCOUNT, and IObjectModel.h .

Dirk