Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48524

Calling typeof(x) on current object's property x during object creation causes assert failure

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.0
    • 5.6.0 Alpha
    • None
    • Windows 7 x64 SP1
      Qt 5.6.0 alpha x64 (built from v5.6.0-alpha1 git tag)
      MSVC 2013 Compiler (amd64)
      Desktop OpenGL (NVIDIA)

      OSX 10.11
    • 9730574818c80b956946dc26458c839915855196

    Description

      The following minimal standalone Qml example causes an assert failure on 5.6.0 alpha:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      
      Window {
      	visible: true
      
      	property var someProp
      	Component.onCompleted: console.log("typeof someProp:", typeof(someProp));
      }
      

      The stack trace is as follow:

       	msvcr120d.dll!_CrtDbgReportW(int nRptType, const wchar_t * szFile, int nLine, const wchar_t * szModule, const wchar_t * szFormat, ...) Line 279	C++
      >	Qt5Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Line 1599	C++
       	Qt5Cored.dll!QMessageLogger::fatal(const char * msg, ...) Line 784	C++
       	Qt5Cored.dll!qt_assert(const char * assertion, const char * file, int line) Line 3045	C++
       	Qt5Qmld.dll!QV4::RuntimeHelpers::convertToObject(QV4::ExecutionEngine * engine, const QV4::Value & value) Line 440	C++
       	Qt5Qmld.dll!QV4::Value::toObject(QV4::ExecutionEngine * e) Line 305	C++
       	Qt5Qmld.dll!QV4::Runtime::typeofMember(QV4::ExecutionEngine * engine, const QV4::Value & base, int nameIndex) Line 1153	C++
       	Qt5Qmld.dll!QV4::Moth::VME::run(QV4::ExecutionEngine * engine, const unsigned char * code) Line 688	C++
       	Qt5Qmld.dll!QV4::Moth::VME::exec(QV4::ExecutionEngine * engine, const unsigned char * code) Line 960	C++
       	Qt5Qmld.dll!QV4::SimpleScriptFunction::call(const QV4::Managed * that, QV4::CallData * callData) Line 580	C++
       	Qt5Qmld.dll!QV4::Object::call(QV4::CallData * d) Line 310	C++
       	Qt5Qmld.dll!QQmlJavaScriptExpression::evaluate(QV4::CallData * callData, bool * isUndefined) Line 189	C++
       	Qt5Qmld.dll!QQmlBoundSignalExpression::evaluate(void * * a) Line 239	C++
       	Qt5Qmld.dll!QQmlBoundSignal_callback(QQmlNotifierEndpoint * e, void * * a) Line 333	C++
       	Qt5Qmld.dll!QQmlNotifier::emitNotify(QQmlNotifierEndpoint * endpoint, void * * a) Line 96	C++
       	Qt5Qmld.dll!QQmlData::signalEmitted(QAbstractDeclarativeData * __formal, QObject * object, int index, void * * a) Line 774	C++
       	Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3622	C++
       	Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3600	C++
       	Qt5Qmld.dll!QQmlComponentAttached::completed() Line 136	C++
       	Qt5Qmld.dll!QQmlObjectCreator::finalize(QQmlInstantiationInterrupt & interrupt) Line 1216	C++
       	Qt5Qmld.dll!QQmlComponentPrivate::complete(QQmlEnginePrivate * enginePriv, QQmlComponentPrivate::ConstructionState * state) Line 914	C++
       	Qt5Qmld.dll!QQmlComponentPrivate::completeCreate() Line 951	C++
       	Qt5Qmld.dll!QQmlComponent::completeCreate() Line 942	C++
       	Qt5Qmld.dll!QQmlComponent::create(QQmlContext * context) Line 775	C++
       	qmlscene.exe!main(int argc, char * * argv) Line 566	C++
       	qmlscene.exe!__tmainCRTStartup() Line 626	C
       	qmlscene.exe!mainCRTStartup() Line 466	C
       	kernel32.dll!BaseThreadInitThunk()	Unknown
       	ntdll.dll!RtlUserThreadStart()	Unknown
      

      The failed assertion is 'value.isString()' in:

      Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Value &value)
      {
          Q_ASSERT(!value.isObject());
          switch (value.type()) {
          case Value::Undefined_Type:
          case Value::Null_Type:
              engine->throwTypeError();
              return 0;
          case Value::Boolean_Type:
              return engine->newBooleanObject(value.booleanValue());
          case Value::Managed_Type:
              Q_ASSERT(value.isString());
              return engine->newStringObject(value.stringValue());
          case Value::Integer_Type:
          default: // double
              return engine->newNumberObject(value.asDouble());
          }
      }
      

      I've attached the minimal example, along with a .qmlproject file.

      Attachments

        1. typeof_test.zip
          0.9 kB
          Alexandre Cossette-Pacheco

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              erikv Erik Verbruggen
              acossette Alexandre Cossette-Pacheco
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes