Hope you know these days I'm trying Qt\C++. Today I spent lot of my valuable time for solve the error mentioned in the title (ASSERT: "uint(i) < uint(size())" in file bla.. bla.., line bla..). It is run time error and I tried lot to find what was happening. At that time I have no knowledge about the 'Q_ASSERT' also.
A one bug hidden inside below code. Can you find it?
A one bug hidden inside below code. Can you find it?
for (int row = 0; row < heights().count(); ++row)
{
for (int col = 0; col < ampererates().count(); ++col)
{
QModelIndex index = item_model->index(row,col,QModelIndex());
no_of_components = item_model->data(index).toString();
if(no_of_components.toInt()>0)
{
height = heights().at(row);
ampererates = ampererates.at(col);
item_details.clear();
item_details.append(QString::number(selected_width));
item_details.append(height);
item_details.append(amperate);
item_details.append(no_of_components);
selected_components.append(item_details);
}
}
}
I know it is very difficult to found a bug without the whole story. But I'm writing this post to anyone who got the same problem as a beginner like me and detail about my thinking pattern.
As a first step I put qDebug() s intermediate of the lines. And I found the bug in below line.
ampererates = ampererates.at(col);
Then I thought what type of error it was. It mentioned something about sizes. Sizes?? something about arrays or List..?? Then I thought if there is no error in count() of the same list. Why it was informing error like out of bound?
for (int col = 0; col < ampererates().count(); ++col) Working fine.
ampererates = ampererates.at(col); ++col) Not working
Variable ampererates is QString. And ampererates() is QStringList. Ohh.. Shit.. I missed the brackets. Solution founded. I was trying to read a char from QString instead of read string from QStringList. There is no guarantee that index position is valid.
Then I checked what .at() doing in different classes. As mentioned in there class references.
const QChar QString::at ( int position ) const
Returns the character at the given index position in the string.
The position must be a valid index position in the string (i.e., 0 <= position < size()).const T & QList::at ( int i ) const
Returns the item at index position i in the list. i must be a valid index position in the list (i.e., 0 <= i < size()).
This function is very fast (constant time).QStringList inhereted from QList.
OK. Thinks this is help somebody to solve same issue. I'm going to learn further what 'Q_ASSERT' do.
Thanks for reading. Have a nice day.
I don't know whether it's just me or if perhaps everyone else
ReplyDeleteexperiencing issues with your site. It appears as though some
of the text within your posts are running off the screen. Can somebody else please
comment and let me know if this is happening to them as well?
This may be a problem with my internet browser because I've had this happen previously.
Many thanks
Also visit my web blog - Used Repo Cars For Sale In Michigan
moncler
ReplyDeleteoff white
ralph lauren outlet
canada goose outlet
red bottom
true religion outlet store
nike air max 95 ultra
coach outlet store online
kate spade sale
skechers outlet
شركة كشف تسربات المياه بالرياض
ReplyDeleteشركة تنظيف بيارات بالرياض
شركة تسليك مجاري بالرياض
شركة تنظيف مسابح بالرياض
شركة تنظيف واجهات حجر بالرياض
Arranging and organizing the house
The workers of your home company do not leave the house in a mess after cleaning it, but they arrange everything in its place, organizing it beautifully and impressively. The house looks brightly dressed for everyone who sees it.
golden goose sale
ReplyDeletejordan shoes
off white shoes
pandora charms
pandora
yeezys
pandora outlet
curry
golden goose
air jordan
It looks to me that this web site doesn
ReplyDeletereally liked the post you posted . it just isnt that easy to discover even remotely good posts toactually read (you know.. really READ and not simply browsing through it like a zombie before going to yet another post to just ignore), so cheers man for not wasting my time on the god forsaken internet.
Just browsing your blog, how long have you had it? I love the design.
TOP Google Ranking On Your Site
Utterly understand what your stance in this matter. Though Id disagree on some of the finer particulars, I think you did an superior job explaining it. Certain beats having to analysis it on my own. Thanks. Anyway, in my language, there arent a lot good supply like this.Sarah Berger
ReplyDeletecheck these guys out see this check my reference wikipedia reference great site her latest blog
ReplyDeletenavigate to this website replica bags from korea visit our website replica bags high quality look at these guys replica bags wholesale mumbai
ReplyDelete