Browse Source

CustomPlugin: Use qobject_cast

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
QGC4.4
Tomaz Canabrava 6 years ago committed by Daniel Agar
parent
commit
42ad3de71b
  1. 2
      custom-example/src/CustomPlugin.cc

2
custom-example/src/CustomPlugin.cc

@ -47,7 +47,7 @@ customQuickInterfaceSingletonFactory(QQmlEngine*, QJSEngine*) @@ -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 {

Loading…
Cancel
Save