[Qt-creator] RunMode in Analyzer plugin

Nicolas Arnaud-Cormos nicolas.arnaud-cormos at kdab.com
Sun Jan 15 18:52:20 CET 2012

On Sunday 15 January 2012 11:46:42 André Pönitz wrote:
> On Fri, Jan 13, 2012 at 10:14:03PM +0100, Nicolas Arnaud-Cormos wrote:
> > Hi,
> > 
> > Since commit a6ff74c0, the run mode changes from a string to an enum.
> > Unfortunatelly, it means there's no way to add a new mode (except by
> > changing the code): no way to create any new analyzer 3rd party plugin.
> Sure. Pick a random integer and be done. There's a chance of clashs,
> but there also a chance of clashs when using random strings, even if
> it's smaller, the harm is done.

Right, a (RunMode)0x1234 works. Thanks I totally miss this possiblity.

> If the clashs are a _real_ issue we should probably device a method
> to assign an range of integers to a plugin that can be "safely" used
> as "id" in any creator "id" context. Qt used to have something for
> Qxxx suffixes and I am not aware of a case where this was a problem.

I don't expect tons of 3rd party plugins that could clash, we may need it once 
we find a clash.

> > I see two possible solutions:
> >  * revert the commit
> >  * use int instead of the enum in the different methods, and add a
> >  * UserMode in the enum
> I went for an enum because it shows its name in the debugger. You can
> cast an int to an enum if you want, so this is not a restriction.
> We could indeed add a 'UserMode' style value, though, to keep some
> room for 'official' values.

As long as people don't use low integer, that's ok. But I like the UserMode 
enum, makes thing a bit more official.

> > What's wrong with the string?
> Last time I checked we spend around 8% on string related code on startup
> where there shouldn't be that much. Part of it was due to some
> utf16->utf16 (sic!) conversion but there's still a measurable part due
> to using strings as ids all over the place.
> Creator is growing quickly, we need to be cautious when it comes to
> selecting "convenient" approaches that have consequences for performance
> and size.

Interesting, thanks for sharing this. Indeed, we should probably reduce the 
memory used by creator, I was quite surprised to see 1.6 Go used on my daily 
project (really big one, most of the memorry is probably used by the AST, I 
will need to profile it to see if there are anything obvious).


Nicolas Arnaud-Cormos | nicolas.arnaud-cormos at kdab.com | Senior Software 
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

More information about the Qt-creator mailing list