Repository navigation
qtvcp: make HAL pin type enums resolvable by uic again - #4846
grandixximo wants to merge 1 commit into
Conversation
|
Wondering,... how long do we need to keep the old names? |
|
Agreed, they do not need to stay in the enum. I dropped BIT, S32 and FLOAT from HALPinType and moved the compatibility into a metaclass on HalBar, PushButton and HALPad: its |
uic resolves `<enum>HalBar::REAL</enum>` with getattr(HalBar, 'REAL'). Since the HAL API break those class attributes were hal.Type members, which the HALPinType property rejects, so HalBar, PushButton and HALPad always came up with their default pin type. On qtdragon_lathe the load bars became SINT and lathe_postgui.hal failed to link them to joint.N.vel-cmd. Give the three classes a metaclass whose __getattr__ answers uic from HALPinType, instead of keeping a second hand-written list of class attributes. BIT, S32 and FLOAT are no longer HALPinType members; the metaclass maps them to BOOL, SINT and REAL for .ui files saved before 2.10, with a warning to resave the file in Designer. Fixes LinuxCNC#4843
2665322 to
dbf615d
Compare
| # uic resolves <enum>HalBar::REAL</enum> with getattr(HalBar, 'REAL'), so | ||
| # the class must answer the names of its HALPinType. Names from .ui files | ||
| # saved before 2.10 map to the current ones, with a warning. | ||
| class HalPinTypeMeta(type(QDialog)): |
There was a problem hiding this comment.
The comment suggests that it is only for HalBar, but it is now used as a base class to resolve the old types and warn for others as well.
| if new in pintype.__members__: | ||
| if (cls.__name__, name) not in HalPinTypeMeta._warned: | ||
| HalPinTypeMeta._warned.add((cls.__name__, name)) | ||
| LOG.warning('{0}::{1} is an old pin type name, use {0}::{2}. ' |
|
|
||
| class ScaledLabel(QtWidgets.QLabel): |
There was a problem hiding this comment.
Nitpicking ;-) Not sure why the extra empty line was added.
|
|
||
|
|
|
|
||
| if __name__ == '__main__': |
Fixes #4843.
uic resolves
<enum>HalBar::REAL</enum>withgetattr(HalBar, 'REAL'). Since the HAL API break those class attributes arehal.Typemembers, which theHALPinTypeproperty rejects, so HalBar, PushButton and HALPad always come up with their default pin type. On qtdragon_lathe the load bars become SINT andlathe_postgui.halfails to link them tojoint.N.vel-cmd, so the config does not start.I give the three classes a metaclass whose
__getattr__answers uic fromHALPinType, instead of keeping a second hand-written list of class attributes. BIT, S32 and FLOAT are no longerHALPinTypemembers, so Designer only offers and writes the current names; the metaclass maps the old names for .ui files saved before 2.10, with a warning to resave the file in Designer.I ran sim.qtdragon_lathe.basic_xz_lathe before and after: before it stops after loading the postgui file, after it starts with both load pins real and linked. With the .ui rewritten to
HalBar::FLOATit also starts with real pins and logs the warning once.@BsAtHome, this touches the type names from the API break, could you have a look?