Unexpected QList behaviour with nested structures.
-
What makes you believe that this is a QList problem?
It could also be that the memory of the original char * has been released. -
released WHERE? in foreach() or at() ?? and it can't be released anywhere because it is statically initialized - it contains pointer to static "string"
of course may be I'm just getting tired... working for 14 hours today... may be...
-
Your code has a lot of bugs and won't even compile.
@char* x1 = pair.v1.str; // is fine@
No, this is not fine because you assign a const char* to a char* without a const cast.
@QObject x2 = tmp.v1.obj; // is fine@
No, this is even more worse because you assign a QObject pointer to a QObject instance.
From reading your code I'm not surprised that QList shows unexpectet behaviour. But maybe the QList programmer created a serious bug because he was tired after 14 hours of work. ;) -
Gourmand, this is the third topic in a short time where you claim very well tested Qt libs have bugs. Perhaps you should mind "this item":http://www.catb.org/~esr/faqs/smart-questions.html#id478549 from the "Smart Questions FAQ":http://www.catb.org/~esr/faqs/smart-questions.html.
-
bq. Your code has a lot of bugs and won’t even compile.
this was not exactly copy-pasted code, here was just idea, exactly there was my mistake but not in this code, in other place, now all this work fine, sorry
-
@ const QObject* obj; @
You cannot have a const pointer and then assign to it normally. Only in the initializer list of constructor or when defining it. Either
@
const QObject* obj = <some_qobject_pointer>;
@or
@
struct ABC {ABC(QObject* obj_param) : obj(obj_param) { } const QObject* obj;
};
QObject* myObj = new QObject();
struct ABC a(myObj);
@Other issues in the code, you don't allocate memory anywhere..
Do this:@
struct ABC
{
char* str;
}struct ABC a;
a.str = strdup("your const char* string");
@strdup duplicates string, allocates memory and returns it.
If you say, it's solved, then could you add [ Solved ] in the title.
-
bq. You cannot have a const pointer and then assign to it normally.
You can't read? I already told - real code was different. I was after 14 hours of permanent work and entered wrong code here. All my tens of thousands lines work fine.
Anybody can close this thread?
-
[quote author="Gourmand" date="1308662520"]You can't read? I already told - real code was different. I was after 14 hours of permanent work and entered wrong code here. All my tens of thousands lines work fine.
Anybody can close this thread?[/quote]
People here are trying to help you Gourmand, so please be nice and watch what you write.
-MariusG
Admin -
I already don't need help. When I'll need - I'll ask for it. Sorry. Please close this thread.
-
Gourmand: please be patient. All people here are here because they like Qt and in their free time. If you get rude, you will get no answers. So I suggest, you keep being patient.
EDIT: closed the thread