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

Qml Android application crashes if QApplication::quit is called during initialization

XMLWordPrintable

    • Android
    • 48d93e0d854b3f9a2486a2393fee38496fd57bd9 (qtdeclarative)

      Qml Android application crashes with system error dialog if Back key is pressed when Qml Engine is created but window is not shown yet.
      The cause is this code in qtbase/src/gui/kernel/qguiapplication.cpp:

      void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
      ...
      #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
      ...
      if (!window)
      qApp->quit();
      else
      QWindowSystemInterface::handleCloseEvent(window);
      }
      #endif

      The sudden qApp->quit() causes crashes inside of the Qml Engine, for example:

      Program received signal SIGSEGV, Segmentation fault.
      [Switching to Thread 7351]
      0x5f322806 in QMutex::lock() () from <...>/libQt5Core.so
      (gdb) bt
      #0 0x5f322806 in QMutex::lock() ()
      from <...>/libQt5Core.so
      #1 0x5fc52208 in QV4::ExecutableAllocator::allocate(unsigned int) ()
      from <...>/libQt5Qml.so
      #2 0x5fbcbb1e in JSC::LinkBuffer::linkCode(void*, JSC::JITCompilationEffort) ()
      from <...>/libQt5Qml.so
      #3 0x5fbbf756 in QV4::JIT::Assembler::link(int*) ()
      from <...>/libQt5Qml.so
      #4 0x5fbc0cbb in QV4::JIT::InstructionSelection::run(int) ()
      from <...>/libQt5Qml.so
      #5 0x5fb3e16f in QV4::EvalInstructionSelection::compile(bool) ()
      from <...>/libQt5Qml.so
      #6 0x5fc4fe6b in QV4::Script::precompile(QV4::IR::Module*, QV4::Compiler::JSUnitGenerator*, QV4::ExecutionEngine*, QUrl const&, QString const&, QList<QQmlError>*) () from <...>/libQt5Qml.so
      #7 0x5fcdbe02 in QQmlScriptBlob::dataReceived(QQmlDataBlob::Data const&) ()
      from <...>/libQt5Qml.so
      #8 0x5fcccc28 in QQmlDataLoader::setData(QQmlDataBlob*, QQmlDataBlob::Data const&) ()
      from <...>/libQt5Qml.so
      #9 0x5fccccfe in QQmlDataLoader::setData(QQmlDataBlob*, QByteArray const&) ()
      from <...>/libQt5Qml.so
      #10 0x5fcd0f66 in QQmlDataLoader::networkReplyFinished(QNetworkReply*) ()
      from <...>/libQt5Qml.so
      #11 0x5fcd1250 in QQmlDataLoaderNetworkReplyProxy::manualFinished(QNetworkReply*) ()
      from <...>/libQt5Qml.so
      #12 0x5fcd5006 in QQmlDataLoader::loadThread(QQmlDataBlob*) ()
      from <...>/libQt5Qml.so
      #13 0x5fcd557c in QQmlDataLoader::load(QQmlDataBlob*, QQmlDataLoader::Mode) ()
      from <...>/libQt5Qml.so
      #14 0x5fcd586c in QQmlTypeLoader::getScript(QUrl const&) ()
      from <...>/libQt5Qml.so
      #15 0x5fcd7227 in QQmlTypeData::resolveTypes() ()
      from <...>/libQt5Qml.so
      #16 0x5fcd8572 in QQmlTypeData::allDependenciesDone() ()
      from <...>/libQt5Qml.so
      #17 0x5fcccc94 in QQmlDataLoader::setData(QQmlDataBlob*, QQmlDataBlob::Data const&) ()
      from <...>/libQt5Qml.so
      #18 0x5fccccfe in QQmlDataLoader::setData(QQmlDataBlob*, QByteArray const&) ()
      from <...>/libQt5Qml.so
      #19 0x5fcd0f66 in QQmlDataLoader::networkReplyFinished(QNetworkReply*) ()
      from <...>/libQt5Qml.so
      #20 0x5fcd1250 in QQmlDataLoaderNetworkReplyProxy::manualFinished(QNetworkReply*) ()
      from <...>/libQt5Qml.so
      #21 0x5fcd5006 in QQmlDataLoader::loadThread(QQmlDataBlob*) ()
      -Type <return> to continue, or q <return> to quit-
      from <...>/libQt5Qml.so
      #22 0x5fcd5468 in QQmlDataLoaderThread::loadThread(QQmlDataBlob*) ()
      from <...>/libQt5Qml.so
      #23 0x5fcc87ca in void QQmlThread::postMethodToThread<QQmlDataBlob*, QQmlDataBlob*, QQmlDataLoaderThread>(void (QQmlDataLoaderThread:(QQmlDataBlob), QQmlDataBlob* const&)::I::call(QQmlThread*) ()
      from <...>/libQt5Qml.so
      #24 0x5fd31d8a in QQmlThreadPrivate::threadEvent() ()
      from <...>/libQt5Qml.so
      #25 0x5fd32430 in QQmlThreadPrivate::event(QEvent*) ()
      from <...>/libQt5Qml.so
      #26 0x60a55074 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
      from <...>/libQt5Widgets.so
      #27 0x60a5ab41 in QApplication::notify(QObject*, QEvent*) ()
      from <...>/libQt5Widgets.so
      #28 0x5f587cfb in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
      from <...>/libQt5Core.so
      #29 0x5f58ecbe in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
      from <...>/libQt5Core.so
      #30 0x5f5e9acb in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
      from <...>/libQt5Core.so
      #31 0x5f5846a7 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
      from <...>/libQt5Core.so
      #32 0x5f5848e7 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
      from <...>/libQt5Core.so
      #33 0x5f3254f7 in QThread::exec() ()
      from <...>/libQt5Core.so
      #34 0x5fd318d9 in QQmlThreadPrivate::run() ()
      from <...>/libQt5Qml.so
      #35 0x5f32b511 in QThreadPrivate::start(void*) ()
      from <...>/libQt5Core.so
      #36 0x400565a9 in __thread_entry () from <...>/libc.so
      #37 0x4006f5d5 in __pthread_clone () from <...>/libc.so

      It is much lesser evil just to ignore the Back key in such situation.
      But a perfect solution would be to postpone it until app window is displayed and then close the app normally through QWindowSystemInterface::handleCloseEvent(window);

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

            shausman Simon Hausmann
            thelivingone Sergey Galin
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes