Skip to content
Snippets Groups Projects
Commit 98b04191 authored by Lyndon Brown's avatar Lyndon Brown Committed by Jean-Baptiste Kempf
Browse files

qt: clean up control `getType()`

 1. the name suggests that it returns an item's type, yet in fact it
    returns the item's type class, so essentially it gives up false
    information, as named. (one exception is the hotkey group control which
    actually does give up its specific type, yet that is somewhat a lie also
    because the control does not represent a single config item).
 2. any efficiency gain from returning a hard-coded value is dwarfed by the
    mess and fragility of having a collection of implementations cluttering
    the files, returning hard coded values. it is much more straight
    forward to just return the item's actual type value, and either let the
    caller use `CONFIG_CLASS()` on it where appropriate, (or do it for them
    with a more suitably named method).
 3. this method is only used in one single place, the open-capture-advanced
    code, so is certainly not worth the mess.

this reworks the method to a single implementation on the base class, which
just returns an item's raw and actual type.

to account for the special hotkey group control which has a null item
pointer since it is not linked to a single config item unlike all other
controls, it guardedly returns `-1` if the item pointer is null.

the one user of this function, (which happens to have no interest in the
hotkey control), now gets the raw type, asserts that it did not unexpectedly
get `-1` to protect against any future mistake, reduces the type down to
type class itself to get the info it actually wants, and proceeds from there
as normal.
parent 3340d3cc
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment