Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, September 2007
QListWidget Crash on clear


Message 1 in thread

I am running into a very annoying problem with  program I am writing  
in Qt 4.3.0 on Mac OS X. Specifically, whenever I call the clear()  
function on a QListWidget with an item currently selected, my program  
exits "with status value:1". Note that it does not seg fault, it just  
cleanly exits with status value 1, leaving the debugger running with  
nothing connected. Note also that this doesn't happen with a  
QListView object. Immediately prior to the crash the debugger does  
show the error "ASSERT failure in QList<T>::operator[]: "index out of  
range", file /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks/ 
QtCore.framework/Headers/qlist.h, line 379" which does explain why it  
is crashing, but not why this error is occurring.

Other things I have tried:
1) Attempting to de-select the item by calling  
QListWidget::setCurrentRow(-1) (which I am using and works fine on a  
QListView) causes the same error/crash (is there a different/better  
way to do this? it would appear that -1 is the "current item" on a  
list with nothing selected).
2) Using the takeItem() function (yes, I know, this isn't really a  
proper use of the function, as it doesn't delete the QListWidgetItem  
from memory, but it looks the same in the GUI for testing purposes)  
on the only item in the list also causes the same error/crash-even  
though the item isn't actually deleted.
3) Calling takeItem() on the selected item (unless it is the last  
item in the list, in which case see #2) causes a seg fault (Program  
received signal:  "EXC_BAD_ACCESS")-on all other other items it works  
fine.

Any of the above operations (with the possible exception of the  
setCurrentRow, which I haven't tried) work fine on a QListWidget with  
nothing selected. Note also that I have not tried this on other  
platforms yet- I may see what happens on windows at some point. Is  
there something I can do to fix this problem? Thanks.

-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------


--
 [ signature omitted ] 

Message 2 in thread

Ok, this one was my problem-turns out I wasn't doing enough range  
checking in my currentItemChanged slot where it was referencing an  
array, so when the current item changed to -1 it crashed. Oops :-P
-----------------------------------------------
Israel Brewster
Computer Support Technician
Frontier Flying Service Inc.
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7250 x293
-----------------------------------------------


On Sep 19, 2007, at 9:50 AM, Israel Brewster wrote:

> I am running into a very annoying problem with  program I am  
> writing in Qt 4.3.0 on Mac OS X. Specifically, whenever I call the  
> clear() function on a QListWidget with an item currently selected,  
> my program exits "with status value:1". Note that it does not seg  
> fault, it just cleanly exits with status value 1, leaving the  
> debugger running with nothing connected. Note also that this  
> doesn't happen with a QListView object. Immediately prior to the  
> crash the debugger does show the error "ASSERT failure in  
> QList<T>::operator[]: "index out of range", file /Developer/SDKs/ 
> MacOSX10.4u.sdk/Library/Frameworks/QtCore.framework/Headers/ 
> qlist.h, line 379" which does explain why it is crashing, but not  
> why this error is occurring.
>
> Other things I have tried:
> 1) Attempting to de-select the item by calling  
> QListWidget::setCurrentRow(-1) (which I am using and works fine on  
> a QListView) causes the same error/crash (is there a different/ 
> better way to do this? it would appear that -1 is the "current  
> item" on a list with nothing selected).
> 2) Using the takeItem() function (yes, I know, this isn't really a  
> proper use of the function, as it doesn't delete the  
> QListWidgetItem from memory, but it looks the same in the GUI for  
> testing purposes) on the only item in the list also causes the same  
> error/crash-even though the item isn't actually deleted.
> 3) Calling takeItem() on the selected item (unless it is the last  
> item in the list, in which case see #2) causes a seg fault (Program  
> received signal:  "EXC_BAD_ACCESS")-on all other other items it  
> works fine.
>
> Any of the above operations (with the possible exception of the  
> setCurrentRow, which I haven't tried) work fine on a QListWidget  
> with nothing selected. Note also that I have not tried this on  
> other platforms yet- I may see what happens on windows at some  
> point. Is there something I can do to fix this problem? Thanks.
>
> -----------------------------------------------
> Israel Brewster
> Computer Support Technician
> Frontier Flying Service Inc.
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7250 x293
> -----------------------------------------------
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]