Bacon2D/Bacon2D

Scene.debug doesn't work if is set directly

rpadovani opened this issue · 8 comments

The debug property of Scene doesn't work if is set in the Scene itself, you have to declare after the component is completed.

This doesn't work:
Scene { debug: true }

This works:
Scene { Component.onCompleted: debug = true }

I can't reproduce this. I tried adding debug: true in the the fixtures example and I added it in your 100ballls.qml, both worked fine. Can you try to testing it in the fixtures example?

That is the same problem I had setting currentScene in Game component.

If Game has size 0,0, the Scene is a direct child of Game, and it has anchors.fill: parent, and in the Game currentScene is set to Scene, then the Scene is correctly rendering, but there isn't the debug mode.

This isn't properly a bug, but it's a bit confusing, because the Scene has a right render, but there isn't debug mode.

You can reproduce with something like this:

Component {
  Game {
    anchors.centerIn: parent
    anchors.fill: parent
    Scene {
      anchors.fill: parent
      physics: true
      debug: true
      running: true
    }
  }
}

Maybe a warning when the size of Game component is 0,0 could be useful?

I'll need to figure out the right place to add the warning. I'm suspecting it refuses to add the debug overlay because the box2d world isn't ready yet. The world might not be initialized until it gets a size, box2d is very dependent on position stuff.

Or perhaps I can handle that on geometryChanged in the scene, if m_debug is true and there is now DebugDraw over the scene, add it.

I think it would be cleaner to add the warning on the documentation of this property instead of throw it on stdout or something similar.

I think we should do both, add a warning message and write about it in the documentation. Maybe display a warning in Scene::setDebug

These initialization problems keep happening because we override componentComplete and mess the initialization order... maybe we can think of a different approach, some kind of lazy initialization for our elements or something like it

I don't think that's the cause of this, i suspect the world isn't valid when it's 0,0. I'll look deeper.

If you are on Ubuntu you can simply reproduce it with first version of my app: https://github.com/rpadovani/100balls/tree/7b684616ab0467122e06fd03135b7aa07c4876d4

Game doesn't have size, but Scene in rendered as should be, and debug doesn't work