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

QSA-interest Archive, September 2005
Bug in QInterpreter::presentObjects() ?


Message 1 in thread

Hi
After registering Objects to an interpreter using addObjectFactory I got 
errors executing a script like this:
	var obj = new MyObj;
That for I would like to figure out what objectsnames get recognized by the 
interpreter and if "MyObj" is part of it. But using 
QInterpreter::presentObjects() ends up in a segmentation-fault.

demonstration app:
#include <QtGui>
#include <qsinterpreter.h>
#include <qsproject.h>

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QMainWindow mainWin;

	QSProject* pSProject = new QSProject();
	pSProject->interpreter()->presentObjects();

	mainWin.show();
	return app.exec();
}

Any ideas ?
	Greetings
		Jens

Attachment:

Attachment: qsa-presentObjects.tar.gz
Description: application/tgz


Message 2 in thread

Jens wrote:
> Hi
> After registering Objects to an interpreter using addObjectFactory I got 
> errors executing a script like this:
> 	var obj = new MyObj;
> That for I would like to figure out what objectsnames get recognized by the 
> interpreter and if "MyObj" is part of it. But using 
> QInterpreter::presentObjects() ends up in a segmentation-fault.
> 
> demonstration app:
> #include <QtGui>
> #include <qsinterpreter.h>
> #include <qsproject.h>
> 
> int main(int argc, char *argv[])
> {
> 	QApplication app(argc, argv);
> 	QMainWindow mainWin;
> 
> 	QSProject* pSProject = new QSProject();
> 	pSProject->interpreter()->presentObjects();
> 
> 	mainWin.show();
> 	return app.exec();
> }

Hi Jens,

The patch below fixes the crash. Please note however that 
QSInterpreter::presentObjects returns you the list of objects added via 
QSInterpreter::addTransientObject() and QSProject::addObject(), not 
normal values created in script.

best regards,
Gunnar

==== qsa/src/qsa/qsinterpreter.cpp#25 - qsa/src/qsa/qsinterpreter.cpp ====
@@ -624,7 +624,7 @@
      startInterpreter();
      QObjectList *lst = interpreter()->topLevelObjects();
      stopInterpreter();
-    return *lst;
+    return lst ? *lst : QObjectList();
  }

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