google / blockly-android

Blockly for Android
Apache License 2.0
673 stars 209 forks source link

Crash on incorrect connection attempt #587

Open AnmAtAnm opened 7 years ago

AnmAtAnm commented 7 years ago

Steps:

  1. Add a Boolean input, like a "not" / logic_negate block.
  2. Connect a Boolean output to it, like a "true" logic_boolean.
  3. Add to the workspace a default math_number_property block, with a single empty input (not set to "is divisible by").

Result: Crash when it attempt to reconnect the prior child to empty math_number_property input, which needs a Number, not a Boolean.

java.lang.IllegalArgumentException: Cannot connect, checks do not match.
    at com.google.blockly.model.Connection.checkConnection(Connection.java:390)
    at com.google.blockly.model.Connection.connect(Connection.java:156)
    at com.google.blockly.android.control.BlocklyController.connectAsInput(BlocklyController.java:1464)
    at com.google.blockly.android.control.BlocklyController.connectAsInput(BlocklyController.java:1482)
    at com.google.blockly.android.control.BlocklyController.connectImpl(BlocklyController.java:1622)
    at com.google.blockly.android.control.BlocklyController.access$800(BlocklyController.java:75)
    at com.google.blockly.android.control.BlocklyController$12.run(BlocklyController.java:809)
    at com.google.blockly.android.control.BlocklyController.groupAndFireEvents(BlocklyController.java:542)
    at com.google.blockly.android.control.BlocklyController.connect(BlocklyController.java:806)
    at com.google.blockly.android.ui.Dragger.maybeConnectDragGroup(Dragger.java:350)
    at com.google.blockly.android.ui.Dragger.access$400(Dragger.java:53)
    at com.google.blockly.android.ui.Dragger$2.onDrag(Dragger.java:216)

It's questionable whether the block should be chained, even if the types match, considering it is not the last Input.