Bug 361785

Summary: processor cores are shown in incorrect sequence is > 10
Product: [Frameworks and Libraries] frameworks-solid Reporter: Marius Cirsta <marius_mps>
Component: generalAssignee: Lukáš Tinkl <lukas>
Status: CONFIRMED ---    
Severity: normal CC: kde, kdelibs-bugs-null, nix.or.die
Priority: NOR    
Version First Reported In: 5.20.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: patch to sort processors based on cpu number

Description Marius Cirsta 2016-04-14 23:08:59 UTC
Solid gets its info by querying udev I presume but the cores numbers are sorted based on strings and not on numerical order:

 if you have 12 cores you will have :

 0 1 11 12 2 3 4 ... so the problem is that 11 and 12 < 2 .


Reproducible: Always

Steps to Reproduce:
1. Open device viewer from Device Information in KInfocenter but to observe the bug you need more than 10 cores
2.
3.
Comment 1 Marius Cirsta 2016-04-15 23:37:29 UTC
Created attachment 98416 [details]
patch to sort processors based on cpu number
Comment 2 Gabriel C 2016-10-24 16:37:55 UTC
Same bug exists in 5.27.0
Comment 3 David Edmundson 2016-10-26 17:04:44 UTC
Thanks for the patch, just so you know, we tend to use http://git.reviewboard.kde.org for patches, ones on bugs tend to get missed, particularly in less active components.

The patch itself could do with some work; 

right now you're effectively resorting the entire list on every insert, and with a regular expression too.

You should be able to identify where in the list to insert, then insert at that position using:

auto  place = std::lower_bound(list.constStart, list.constEnd, newItem, compareFunction);
list.insert(place, newItem);

also instead of a regular expression you should be able to use QCollator with http://doc.qt.io/qt-5/qcollator.html#setNumericMode