mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdecore: do not block while parsing files in KDeviceDatabase
parsing ~30k lines and filling maps for the entries takes some time and could block the events of kinfocenter for example which is noticable because the parsing of files is delayed until a KDeviceDatabase query is made Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
f0c713f831
commit
6ae96c3c1d
1 changed files with 10 additions and 0 deletions
|
@ -21,6 +21,9 @@
|
|||
#include "kdebug.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#define KDEVICEDATABASE_TIMEOUT 100
|
||||
|
||||
struct KDeviceEntry
|
||||
{
|
||||
|
@ -75,12 +78,19 @@ static void extractIDs(QFile *idsfile,
|
|||
{
|
||||
// qDebug() << Q_FUNC_INFO << idsfile->fileName();
|
||||
|
||||
int counter = 0;
|
||||
char idbuffer[5];
|
||||
char strbuffer[1024];
|
||||
bool classessection = false;
|
||||
QByteArray lastvendorid;
|
||||
QByteArray lastdeviceid;
|
||||
while (!idsfile->atEnd()) {
|
||||
counter++;
|
||||
if (counter >= KDEVICEDATABASE_TIMEOUT) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, KDEVICEDATABASE_TIMEOUT);
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
const QByteArray dbline = idsfile->readLine();
|
||||
const QByteArray trimmeddbline = dbline.trimmed();
|
||||
// qDebug() << Q_FUNC_INFO << dbline;
|
||||
|
|
Loading…
Add table
Reference in a new issue