Trolltech Home | QSA-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

QSA-interest Archive, September 2006
QSWrapperFactory with QSProject


Message 1 in thread

I'm using QSA 1.2.1

I modified the example/wrappers to use a QSProject and I get an Qscript
error on startup about using an undefined variable 'listView'.

The modified section looks like:
         QSProject project;
         QSInterpreter *it = project.interpreter();
         // Create interpreter and add listview and factory to it. Order
here is
         // important since adding a wrapper factory will reset the
interpreter.
         it->addWrapperFactory(new Wrappers());
         it->addTransientObject(listView);
         it->evaluate(script, 0, fileName);

If I allocate a new QSInterpreter on the heap then everything works
again.
         QSProject project;
         QSInterpreter *it = project.interpreter();
	   it = new QSInterpeter;
         // Create interpreter and add listview and factory to it. Order
here is
         // important since adding a wrapper factory will reset the
interpreter.
         it->addWrapperFactory(new Wrappers());
         it->addTransientObject(listView);
         it->evaluate(script, 0, fileName);

Is there a way to use the QSWrapperFactory with a QSProject?

Thanks,

Evan

To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx


Message 2 in thread

FARRER, EVAN wrote:
> I'm using QSA 1.2.1
> 
> I modified the example/wrappers to use a QSProject and I get an Qscript
> error on startup about using an undefined variable 'listView'.
> 
> The modified section looks like:
>          QSProject project;
>          QSInterpreter *it = project.interpreter();
>          // Create interpreter and add listview and factory to it. Order
> here is
>          // important since adding a wrapper factory will reset the
> interpreter.
>          it->addWrapperFactory(new Wrappers());
>          it->addTransientObject(listView);
>          it->evaluate(script, 0, fileName);
> 
> If I allocate a new QSInterpreter on the heap then everything works
> again.
>          QSProject project;
>          QSInterpreter *it = project.interpreter();
> 	   it = new QSInterpeter;
>          // Create interpreter and add listview and factory to it. Order
> here is
>          // important since adding a wrapper factory will reset the
> interpreter.
>          it->addWrapperFactory(new Wrappers());
>          it->addTransientObject(listView);
>          it->evaluate(script, 0, fileName);
> 
> Is there a way to use the QSWrapperFactory with a QSProject?

Hi Evan,

The problem here is that the project will contiously reevaluate its 
state to make sure that its allways up-to-date. If you add objects using 
QSInterpreter::addTransientObject() these will be cleared from the 
interpreter whenever the project reevaluates. See the documentation:

http://doc.trolltech.com/qsa-1.2.1/qsinterpreter.html#addTransientObject

The correct function to use to add objects to the project is 
QSProject::addObject();

-
Gunnar

To unsubscribe - send "unsubscribe" in the subject to qsa-interest-request@xxxxxxxxxxxxx