Wednesday, May 26, 2004

Indesign strikes back

This is related to incopy but I think indesign will behave the same because the plugins are cross-application ('till a certain point. i.e. you use specific custom functions).

The problem is another interface leak. The culprit is IWidgetUtils->QueryRelatedWidget, the documentation doesn't say anything particular about it but it looks to me that this method is returning an interface with the reference counter incremented.

I tried to look at the adobe samples but it is never used so I cannot say if I'm doing it wrong or the documentation (both help files and include files) is wrong. Anyway using the static_cast trick explained before solved my problem.

Pay attention to those leaks as soon as you got it, or you will have hard days finding the guilty.

InDesign newbiee problems

I was having an interface leak with InDesign, such leak caused all sort of others leaks that they had the potential to drive me to look at others places, fortunately I've got quite a lot experience with COM interface leaks.

After all the suspecting function was this one:

IPMUnknown* getPanelView(){

InterfacePtr parent(this, UseDefaultIID());
if( parent ) {
InterfacePtr parentPanel(parent->GetParent(), UseDefaultIID());
if( parentPanel )
return parentPanel->QueryParentFor(IID_ICONTROLVIEW);
}
return nil;
} // getPanelView

In particular I was using such function with an InterfacePtr like this:

InterfacePtr<IControlView> panel(getPanelView(), UseDefaultIID());

However if you look at the include file for IWidgetParent, you will find that QueryParentFor will return a reference incremented ptr to interface this means I will leak a reference to that interface. InterfacePtr have a constructor that doesn't call AddRef on the interface and it's the one that didn't do the QueryInterface. So the correct InterfacePtr is:

InterfacePtr<IControlView> panel(getPanelView());

But getPanelView must return an IControlView* or we should cast it here, I prefer the first solution, so I'll have:

IControlView* getPanelView(){

InterfacePtr parent(this, UseDefaultIID());
if( parent ) {
InterfacePtr parentPanel(parent->GetParent(), UseDefaultIID());
if( parentPanel )
return static_cast<IControlView*>(parentPanel->QueryParentFor(IID_ICONTROLVIEW));
}
return nil;
} // getPanelView

Moral of the story: read carefully documentation *and* include files before using any complex sdk.

Friday, May 21, 2004

incredible video

A friend of mine sent me a link to this really funny video I can't understand what they say but it is really really funny.

http://www.hugi.is/hahradi/bigboxes.php?box_id=51208&f_id=1000

Indesign UI

If you are developing a dynamic palette in which you want to host a custom panel, you must be sure that the WidgetID that you will set for the panel must not clash with any of the IDs defined elsewhere.

If they clash you will have some really strange behaviour, for example I aggregated a simple interface to the panel (interface that will give me access to panel's options) but when I assign a conflicting widgetID everyone seems to work except the aggregated interface was not created at all.

I'm not that smart....it took me a couple of days to figure it out.

Monday, May 03, 2004

PNG in Windows IE

PNG in Windows IE

http://homepage.ntlworld.com/bobosola/index.htm

 

How to solve the PNG transparency problem with Ie 5.5 and 6.