[SOLVED] Crash error when deleting a QList< QPair<QString, QString> >
-
Hi,
I'm using Qt 4.8 and the library "O2":https://github.com/pipacs/o2 and I'm facing a crash issue when deleting a QList< QPair<QString, QString> >. The problem is not related to O2 library and I was able to locate which lines cause the crash. Here is the code:
@QUrl getTokenUrl("http://localhost?hello=world");
QList< QPair<QString, QString> > tokens = getTokenUrl.queryItems();
tokens.clear();@But, lines below will not crash (why?):
@QList< QPair<QString, QString> > tokens;
tokens.append(qMakePair<QString, QString>(QUrl::fromPercentEncoding(QByteArray("hello")), QUrl::fromPercentEncoding("world")));
tokens.clear();@I looked in a lot of directions and I don't understand where is the problem.
Any suggestions are welcomed.Regards,
Jonathan -
Hi and welcome to devnet,
Just to rule out the obvious: are you sure the crash happen when clearing tokens ?
Did you run your application through with the debugger ?
-
In that case, are you sure that getTokenUrl.queryItems() returns something that is correct ?
-
Then you need to also check whether any other library you are linking to does follow that
-
Here is my debugger output:
!http://s18.postimg.org/7pyw0reix/qt_bug_qlist.png(debugger output)!
And stack trace after crash occurs:
!http://s15.postimg.org/5u3a6oq2j/qt_bug_stack.png(stack trace)!
-
Did you check that all the libraries you are using are compiled with the same wchart_t options ?
-
Which version of Qt are you using now ? There has been a change in the wchart_t flag, in Qt 5 it's the opposite of what was used for Qt 4
-
I've found the problem by creating a new project and copying the parameters one by one.
The code below crash if I use the Runtime Library option Multi-threaded DLL (/MD) in debug mode (Qt 4.8.5, Visual Studio 2010 with platform toolset v90, 64 bit).
@int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QUrl getTokenUrl(QString::fromLatin1("http://localhost?hello=world"));
QList< QPair<QString, QString> > tokens = getTokenUrl.queryItems();
tokens.clear();return a.exec();
}@This option is needed by my target environment but I'll see if I can do without.
Maybe you have a suggestion?
-
Aren't you using 2010 ?
Which project settings can't you changed ?
-
Did you succeeded ?