[Qt-interest] Problem with QHash and QThread
Andrei Cimpean
andreiamenta at gmail.com
Sat Jun 18 14:07:57 CEST 2011
I am sorry for this. I re-read everything today and saw where I made my
mistake. For everybody who will get in this place again:
don't use const_iterator use iterator.
Thank you for your help.
Andrei
On Sat, Jun 18, 2011 at 3:02 PM, Andrei Cimpean <andreiamenta at gmail.com>wrote:
> I went through the code and this is were the problem appears to be:
>
> QHash<QPoint,int>::const_iterator i = rhombus.points.constBegin();
> while (i != rhombus.points.constEnd()) {
> //first search through the entire hash and for new
> points calculate the SSD
> if(i.value() == -1){
> //position the coordinates of the block at the
> top left corner
> //for easier calculations
> blockTested_x = i.key().x() -
> this->blockSize/2;
> blockTested_y = i.key().y() -
> this->blockSize/2;
> sum = 0;
> //calculate ssd for the current block
> for(int block_i = 0 ; block_i < this->blockSize
> ; block_i++){
> for(int block_j = 0 ; block_j <
> this->blockSize ; block_j++){
> //check if block is out of bonds
> if(blockTested_x > 0 && blockTested_x <
> this->secondFrame->width()-this->blockSize
> && blockTested_y>0 &&
> blockTested_y < this->secondFrame->height()-this->blockSize){
> //if block is valid calculate the
> ssd
> valuesInTestedBlock =
> currentBlockPreparedVals[block_i][block_j]
> -qGray(this->secondFrame->pixel(block_i+blockTested_x,block_j+blockTested_y));
> sum += valuesInTestedBlock *
> valuesInTestedBlock;
> }
> }
> }
> //update the sum value for the current key
> rhombus.points.insert(i.key(),sum);
> }
> ++i;
> }
>
> Thanks.
>
>
>
> On Thu, Jun 16, 2011 at 8:19 PM, Bo Thorsen <bo at fioniasoftware.dk> wrote:
>
>> Your problem is in code you didn't send here. There is nothing in the
>> code you sent that will crash the application.
>>
>> Bo.
>>
>> Den 15-06-2011 00:43, Andrei Sebastian Cîmpean skrev:
>> > Hello everybody,
>> >
>> > I have stumbled upon a problem that I don't quite understand and I was
>> hoping
>> > someone can help me get to the bottom of it.
>> > I have a class that inherits QThread. In the header file I have:
>> >
>> > inline uint qHash(const QPoint& p)
>> > {
>> > return qHash(p.x()+p.y());
>> > }
>> > struct Hexagon{
>> > QPoint center;
>> > int centerSSD;
>> > QHash<QPoint,int> points;
>> > };
>> > class HexagonalSearch : public QThread, public BlockMatching
>> > {
>> > Q_OBJECT
>> > (...)
>> >
>> > , with BlockMatching being a simple class that just has some functions
>> preset.
>> > It compiles without any warnings, although I know that's not necessarily
>> a
>> > condition for no problems.
>> > When I run the app and it gets to part where it has to execute the run()
>> > function the app crashes. I can't debug using Qt Creator (don't know why
>> it
>> > freezes at setting breakpoints even after reinstall) but when I run the
>> > debugger it instantly crashes with the message "The inferior stopped
>> ...." ->
>> > Segmentation fault, and it displays assembly code with a flag set for a
>> > compare (cmpq).
>> > I have attached a screenshot with the result.
>> > Any help would be greatly appreciated and would probably save my life.
>> >
>> > Thank you for your time and patience,
>> > Andrei Sebastian Cîmpean
>> >
>> >
>> >
>> > _______________________________________________
>> > Qt-interest mailing list
>> > Qt-interest at qt.nokia.com
>> > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>>
>> Bo Thorsen,
>> Fionia Software.
>>
>> --
>>
>> Expert Qt and C++ developer for hire
>> Contact me if you need expert Qt help
>> http://www.fioniasoftware.dk
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110618/0071400f/attachment.html
More information about the Qt-interest-old
mailing list