On Wednesday 28 May 2014 22:07:20 Andrey Kozhevnikov wrote: > need to look into your parseReadyData > > 28.05.2014 22:03, Krisztian Olah ?????: > > Hi Andrey, > > > > Thanks for the answer, your snippet looks very similar to what I > > > > have. Perhaps if I posted my code segment would be of help in helping > > me figuring out where I'm wrong. > > > > During parsing CPU usage reaches 97-100% which causes my GUI to > > > > hang(I have about 500 000 opening and closing tags and half of the > > enclosed items I need to process: save, in some cases insert spaces, > > etc), especially awkward when I start parsing whilst still fetching > > the data from network(sometimes hangs during pageStack.push() ), but > > it's bad for up to 2-5 seconds nevertheless. I wouldn't mind if > > parsing took 10 seconds if GUI was responsive. This is what I'm doing: > > > > void SomeClass::someMethod() { > > > > MyContainer* container = new MyContainer(); > > //reader has a handle to container, through which it > > > > populates the container > > > > MyXmlStreamReader* parser = new > > > > MyXmlStreamReader(container); > > > > QThread* parserThread = new QThread(); > > > > parser->moveToThread(parserThread); > > > > connect(parser, SIGNAL(finished()), this, SLOT(onParsingFinished) > > ); > > connect(parser, SIGNAL(finished()), parserThread, SLOT(quit()) ); > > connect(parser, SIGNAL(finished()), parser, SLOT(deleteLater()) > > ); > > connect(parserThread, SIGNAL(finished()), parserThread, > > SLOT(deleteLater()) ); parserThread->start(); > > reply = networkMngr->get(QNetworkRequest(someUrl)); //both > > pointers are class members connect(reply, SIGNAL(finished()), > > this, SLOT(onAllDataRecieved()) ); //this starts the parser with > > the data available at the time, > > > > // when parser reaches the end of xml document it emits > > itsfinished() signal> > > connect(reply, SIGNAL(readyRead()), this, SLOT(parseReadyData()) > > ); > > > > } > >
To run parser in parallel just to get results in the main thread it is better to use QtConcurrent::run() + QFutureWatcher. - denis > > Thanks again > > Kris > > > > > > On 28 May 2014 06:16, Andrey Kozhevnikov <coderusin...@gmail.com > > > > <mailto:coderusin...@gmail.com>> wrote: > > it can't "doesn't help much". you initializing thread wrong. > > > > simple threading way is: > > > > MyXmlParser *parser = new MyXmlParser(xmlDocument); > > QThread *thread = new QThread(parser); > > parser->moveToThread(thread); > > QObject::connect(thread, SIGNAL(started()), parser, SLOT(parse())); > > QObject::connect(parser, SIGNAL(parseComplete(QVariantMap)), this, > > SLOT(onParseComplete(QVariantMap))); > > thread->start(); > > > > 28.05.2014 03:24, Krisztian Olah ?????: > >> Hi list, > >> > >> I have a rather large xml file to parse and it causes the UI to > >> > >> freeze, I assingned the parser to a different thread, but it > >> doesn't help much. According to the Qt documentation > >> QThread::setPriority() doesn't work on Linux, is there some kind > >> of workaround that could be used? > >> > >> Thanks > >> Kris > >> > >> > >> _______________________________________________ > >> SailfishOS.org Devel mailing list > >> To unsubscribe, please send a mail > >> todevel-unsubscr...@lists.sailfishos.org > >> <mailto:devel-unsubscr...@lists.sailfishos.org>> > > _______________________________________________ > > SailfishOS.org Devel mailing list > > To unsubscribe, please send a mail to > > devel-unsubscr...@lists.sailfishos.org > > <mailto:devel-unsubscr...@lists.sailfishos.org> > > > > _______________________________________________ > > SailfishOS.org Devel mailing list > > To unsubscribe, please send a mail to > > devel-unsubscr...@lists.sailfishos.org _______________________________________________ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org