Skip to content

Commit

Permalink
CustomPlugin: Use qobject_cast
Browse files Browse the repository at this point in the history
qobject_cast is times faster then dynamic_cast for objects that
inherit QObject. Also, use auto keyword to not duplicate the
name of the Class
  • Loading branch information
tcanabrava authored and dagar committed Aug 19, 2019
1 parent 3a7ddee commit 42ad3de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom-example/src/CustomPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ customQuickInterfaceSingletonFactory(QQmlEngine*, QJSEngine*)
{
qCDebug(CustomLog) << "Creating CustomQuickInterface instance";
CustomQuickInterface* pIFace = new CustomQuickInterface();
CustomPlugin* pPlug = dynamic_cast<CustomPlugin*>(qgcApp()->toolbox()->corePlugin());
auto* pPlug = qobject_cast<CustomPlugin*>(qgcApp()->toolbox()->corePlugin());
if(pPlug) {
pIFace->init();
} else {
Expand Down

0 comments on commit 42ad3de

Please sign in to comment.