ThemeEngine
ThemeEngine copied to clipboard
Fix for '_enumerateFacets' in 10.15+
Turns out CoreUI.framework has its own implementation of the BOM* functions which are NOT exported.
% nm -a /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI | grep BOM
...
00007fff4228e697 t _BOMTreeIteratorFree
00007fff4228dcf1 t _BOMTreeIteratorIsAtEnd
00007fff4228dd45 t _BOMTreeIteratorKey
00007fff42290791 t _BOMTreeIteratorKeySize
00007fff4228d819 t _BOMTreeIteratorNew
...
In order to get _enumerateFacets working, we only need the CoreUI variants of BOMTreeIteratorNew and BOMTreeIteratorFree.
With these functions being not visible to the linker or dlsym, they have to be resolved manually during runtime. I was able to do this with my libSymRez project like so:
symrez_t sr_coreui = symrez_new("CoreUI");
BOMTreeIteratorRef (*CUIBOMTreeIteratorNew)(BOMTreeRef, int, int, int) = sr_resolve_symbol(sr_coreui, "_BOMTreeIteratorNew");
void (*CUIBOMTreeIteratorFree)(BOMTreeIteratorRef) = sr_resolve_symbol(sr_coreui, "_BOMTreeIteratorFree");
Then replace the functions:
-- BOMTreeIteratorRef iterator = BOMTreeIteratorNew(facet_tree, 0, 0, 0);
++ BOMTreeIteratorRef iterator = CUIBOMTreeIteratorNew(facet_tree, 0, 0, 0);
...
-- BOMTreeIteratorFree(iterator);
++ CUIBOMTreeIteratorFree(iterator);
And we are back in business. It would probably be best to replace all BOM related functions with their CoreUI counterparts but this gets us going.
No idea why _enumerateColors works but _enumerateFacets doesn't.
While this is fixed with current code* it's fascinating still. I'm more curious if this does anything for allowing ThemeEngine to open .car files on Big Sur..
*although perhaps a slightly more aggressive approach?!
The current code isn't "fixing" the issue, its skipping over the issue. But yes, it's a fairly aggressive approach which is why I did not submit a PR for it. Mainly opened this issue to have a discussion about implementation, if it should be done, etc...
@alexzielenski Any ideas?