Unused JS var in unused function + conditional causes QQmlEngine to crash on loading

懵懂的女人 提交于 2019-12-11 07:33:27

问题


This has got to be the weirdest Qt bug I've encountered so far, an unused var in a non-executed function results in a hard crash on QQmlEngine::load().

It takes those few lines of code to reproduce it:

import QtQuick 2.7
import QtQuick.Window 2.2

Window {
  id: main
  visible: true
  width: 500
  height: 300

  function foo() {
    var c = main.width > 1 ? 27 : -147
  }
}

It crashes on both 5.7 and 5.7.1, "stock" GCC builds from the Qt website under windoze 7 x64 and ubuntu 16.04. Adding a simple console.log(c) prevents the crash. Again, note that the function is perfectly legal, no access to any fishy objects whatsoever, and it not even being executed to produce the crash. It looks like something goes terribly wrong when the QML code is being parsed by the engine. The conditional is key here, it doesn't crash without it.

Aside from the implied "what's going on here?" I'd also would take the opportunity to ask people with different platforms or Qt versions whether it affects others, before posting a bug report.

来源:https://stackoverflow.com/questions/41498916/unused-js-var-in-unused-function-conditional-causes-qqmlengine-to-crash-on-loa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!