src/declarative/qml/qdeclarativeobjectscriptclass.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   190     }
   190     }
   191 
   191 
   192     if (!(hints & ImplicitObject)) {
   192     if (!(hints & ImplicitObject)) {
   193         local.coreIndex = -1;
   193         local.coreIndex = -1;
   194         lastData = &local;
   194         lastData = &local;
   195         return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
   195         return QScriptClass::HandlesWriteAccess;
   196     }
   196     }
   197 
   197 
   198     return 0;
   198     return 0;
   199 }
   199 }
   200 
   200 
   623 
   623 
   624     inline void cleanup();
   624     inline void cleanup();
   625 
   625 
   626     char data[4 * sizeof(void *)];
   626     char data[4 * sizeof(void *)];
   627     int type;
   627     int type;
       
   628     bool isObjectType;
   628 };
   629 };
   629 }
   630 }
   630 
   631 
   631 MetaCallArgument::MetaCallArgument()
   632 MetaCallArgument::MetaCallArgument()
   632 : type(QVariant::Invalid)
   633 : type(QVariant::Invalid), isObjectType(false)
   633 {
   634 {
   634 }
   635 }
   635 
   636 
   636 MetaCallArgument::~MetaCallArgument()
   637 MetaCallArgument::~MetaCallArgument()
   637 {
   638 {
   742         type = callType;
   743         type = callType;
   743     } else {
   744     } else {
   744         new (&data) QVariant();
   745         new (&data) QVariant();
   745         type = -1;
   746         type = -1;
   746 
   747 
   747         QVariant v = QDeclarativeEnginePrivate::get(engine)->scriptValueToVariant(value);
   748         QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(engine);
       
   749         QVariant v = priv->scriptValueToVariant(value);
   748         if (v.userType() == callType) {
   750         if (v.userType() == callType) {
   749             *((QVariant *)&data) = v;
   751             *((QVariant *)&data) = v;
   750         } else if (v.canConvert((QVariant::Type)callType)) {
   752         } else if (v.canConvert((QVariant::Type)callType)) {
   751             *((QVariant *)&data) = v;
   753             *((QVariant *)&data) = v;
   752             ((QVariant *)&data)->convert((QVariant::Type)callType);
   754             ((QVariant *)&data)->convert((QVariant::Type)callType);
       
   755         } else if (const QMetaObject *mo = priv->rawMetaObjectForType(callType)) {
       
   756             QObject *obj = priv->toQObject(v);
       
   757             
       
   758             if (obj) {
       
   759                 const QMetaObject *objMo = obj->metaObject();
       
   760                 while (objMo && objMo != mo) objMo = objMo->superClass();
       
   761                 if (!objMo) obj = 0;
       
   762             }
       
   763 
       
   764             *((QVariant *)&data) = QVariant(callType, &obj);
   753         } else {
   765         } else {
   754             *((QVariant *)&data) = QVariant(callType, (void *)0);
   766             *((QVariant *)&data) = QVariant(callType, (void *)0);
   755         }
   767         }
   756     }
   768     }
   757 }
   769 }