En esta página

Bloque de casos no vacío sin terminar

Esta categoría de advertencia se escribe [unterminated-case] por qmllint.

Bloque de casillas no vacío sin terminar

¿Qué ha ocurrido?

Un bloque case en una sentencia switch no estaba vacío pero no estaba terminado por una sentencia break, return o throw. Tampoco había un comentario de exclusión.

¿Por qué es malo?

La lógica fallthrough en las sentencias switch puede ser confusa o pasarse por alto. Si es intencional, debe ser marcada explícitamente con un comentario como "// fallthrough". Si no es intencional, la advertencia indica que se olvidó una sentencia de terminación.

Ejemplo

switch (state) {
case Main.State.Reset:
    clearState()                    // <--- "Unterminated non-empty case block"
case Main.State.Invalid:
    asyncInitState()
    return false
case Main.State.Initializing:
    // wait for initialization to complete
    return false
case Main.State.Ready:
    res = lookup(query)
    log(res.stats)
    saveToDisk(res.data)            // <--- "Unterminated non-empty case block"
default:
    throw new InvalidStateException("Unknown state")
}

Para corregir esta advertencia, añada las sentencias de terminación que faltan o añada comentarios explícitos que permitan la lógica fallthrough:

switch (state) {
case Main.State.Reset:
    clearState()
    // fallthrough                   // <--- add fallthrough comment
case Main.State.Invalid:
    asyncInitState()
    return false
case Main.State.Initializing:
    // wait for initialization to complete
    return false
case Main.State.Ready:
    res = lookup(query)
    log(res.stats)
    saveToDisk(res.data)
    return true                     // <--- add forgotten terminating statement
default:
    throw new InvalidStateException("Unknown state")
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.