[Kwintv] Plugin access to the UI - more problems

Rizsanyi Zsolt rizsanyi at myrealbox.com
Thu Jun 12 01:06:26 CEST 2003


On Monday 02 June 2003 08.23, George Staikos wrote:
> On Sunday 01 June 2003 09:29, Zsolt Rizsanyi wrote:
> > I have ventured further in making the some actions accessible from the
> > telex plugin, but have run in a new problem, though it is quite similar.
> >
> > The gui is not (yet) created when the plugins are initialized.
> > So I dont know how to add an action to one of its toolbars.
> >
> > I tried something like this (tta is an KAction):
> >
> >         KXMLGUIFactory* gui = driver()->guiFactory();
> >         if (gui) {
> >             QWidget* widget = gui->container("viewToolBar", NULL);
> >             if (widget)
> >                 tta->plug(widget);
> >             else
> >                 kdDebug() << "No 'viewToolBar' widget" << endl;
> >         }
> >
> > But this always prints No 'viewToolBar' widget...
> >
> > Could you please advise a way how to do this?
>
>    Argh this is a never-ending cycle here. :-)  Ok I might have to find a
> way to delay plugin initialisation then, maybe through a single-shot timer
> in QtVision*.  I'll play with it and try to commit a new attempt.

Your changes have not immidiately solved the problem. I have had no time to 
check if it is a problem on my side or not.

But the patch has caused many regressions. Many signal/slot connects do not 
succeed, and the popup menu does not appears on right mouse click.
Some of the signal slot connect problems are easily solved, but some are not. 
You initialize some elements (like the osdmanager) in the delayed constructor 
but clients/mainwindow tries to attach a slot to it. It can be only solved by 
adding a delayedconstructor it too. But this can cause more problems and it 
could go forever.

IMO you should change the whole concept in a way where the plugins do not 
access the actionCollection and gui directly, but have some methods which are 
called back when the gui initialization is done.
Eg. add a virtual addActions(ActionCollection&) method to the pluginbase. All 
the plugins who want to add actions would override this method.
Clients (eg. clients/mainwindow) would do normal initialization (without 
delayed constructors ;), and when the initialization is done it would call 
the QtVision::setActionCollection which in turn would call the addActions() 
method of all the initialized plugins.
Of course care should be taken to call addActions on plugin which are turned 
on later (not while the initialization).
This also can have problems but avoids this initialization race we have now.

What do you think? Should we change to this (or some other) method, or try to 
fix all the initialization problems?

Regards
Zsolt



More information about the kwintv mailing list