[SOLVED] Crash in QRegExp::setPattern - Access violation
-
Hi!
I'm using a QRegExp to parse data and get an access violation after setting the 2nd setPattern. The Regex is pointer..
Example Code:
@
regExp = new QRegExp("", Qt::CaseInsensitive, QRegExp::RegExp2);regExp->setPattern("^pokerstars\s+(game|spiel)\s+"); // set the pattern
regExp->exactMatch(*input); // parse subject// some code, then i use setPattern again
regExp->setPattern("^\#([a-zA-Z0-9]+)\:\s"); // set the pattern <-- CRASH
regExp->exactMatch(*input); // parse subject@
A screenshot is here:
http://img41.imageshack.us/img41/4937/screennmm.jpg
d is not accesable...but why? What's wrong here?
Thank you for your help!
-
The snippet works for me. Something most go wrong in the middle. Can you provide a small, complete example so that we can reproduce the error.
Some side notes:
It seems that you use a heap allocated regexp, do you have any reasons for that? The class is lightweight and usually used as stack object.The string you match against seems to be heap allocated too, this is not necessary. With implicit sharing, QString can be passed along without big ovehead. If you need to pass an object that needs to be manipulated, pass a reference.
-
Hi!
Thank you for your answer. I tried QRegExp as a stack object and get the same error. But there's a bit of information i did not provide. I use regExp::setPattern in 2 different functions, but I'm sure that this isn't the problem here.
You gave me some information to work with, but now i want to try solve the problem myself and will inform you about my success or no success. Like learning by doing... :-)
Thank you very much!!!!