Commit 7f161b0a authored by Martin Schultz's avatar Martin Schultz
Browse files

added more documentation on qt signals and the qt event queue which is

a common source for problems when plugins are developed
parent 15593ff8
......@@ -66,4 +66,65 @@ void ExamplePlugin::exampleFunction() {
Of course you have to add the includes for the ObjectTypes you want to use to your list of includes. A list of available
ObjectTypes can be found here: \ref datatypes
\section qt_signals Qt Signals
As mentioned above, new objects are created by emitting the LoadSaveInterface::addEmptyObject signal (more information on Qt signals This signal is connected with a Qt::QueuedConnection which means, that it will be pushed to the Event-Queue of Qt. This allows other plugins to process the new object, e.g. create and add textures for it.
However, after the line "emit addEmptyObject(DATA_PLANE, newObjectId);" from the above example, the event is not necessary processed by all plugins, which may cause problems if they change properties you want to set. To avoid such problems you can inject a new signal to the Event-Queue, because the Event-Queue is processed in order.
Example: YourPlugin.hh:
// LoadSaveInterface
void addEmptyObject( DataType _type, int& _id);
//use this signal to make sure addEmptyObject was processed.
void doStuff(IdList);
void slotDoStuff(IdList _ist);
void YourPlugin::pluginsInitialized()
connect(this, SIGNAL(doStuff(IdList)), this, SLOT(slotDoStuff(IdList)), Qt::QueuedConnection);
void YourPlugin::slotDoStuff(IdList _list)
// You can use whatever plugin you want with your object now
// All others have finished processing addEmptyObject
RPC::callFunctionValue<int>("datacontrol","groupObjects", _list, QString("test_group"));
void YourPlugin::createLotsOfObjects()
//create lots of empty objects by emitting
// addEmptyObject or calling the porimitive generator e.g.
IdList ids;
ids.push_back( RPC::callFunctionValue<int>("primitivesgenerator","addCube",Vector(1.0f),4.0d));
ids.push_back( RPC::callFunctionValue<int>("primitivesgenerator","addCube",Vector(2.0f),4.0d));
// Now use your own signal to make sure the previous signal was consumed by all plugins
// since the connection for this signal is Qt::QueuedConnection,
// it will be inserted at the end of the event queue. and events are processed in order
emit doStuff(ids);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment