PDA

View Full Version : QtColorComboBox leads to a crash when used as an editor in a QItemDelegate derivative



momesana
6th May 2010, 03:58
Hi,
I have implemented a minimal example to showcase an issue I've come across when using QtColorComboBox (http://doc.qt.nokia.com/solutions/4/qtcolorcombobox/qtcolorcombobox.html). When I use the "more" entry to get a custom color and use the "named color entry" in the following color dialog or select a color and press ok or cancel in the same color dialog, the application crashes. Valgrind tells me of invalid reads and writes in the qtcolorcombobox class. I would really appreciate it if someone helped me to find the cause of these crashes. I've attached the test application to this post. The QtColorComboBox class is included in the thirdparty subdirectory so there are no dependecies (except Qt of course) in order to test the application. The valgrind log is also included in the root directory and is called valgrind.log.

Thankx in advance

momesana
7th May 2010, 00:22
Really no ideas? :(

norobro
10th May 2010, 21:55
Might be too late, but I saw this post (http://stackoverflow.com/questions/2468587/c-object-destroyed-in-qcombobox-descendant-editor-in-delegate) that reminded me of your problem.

momesana
22nd May 2010, 05:02
Might be too late, but I saw this post (http://stackoverflow.com/questions/2468587/c-object-destroyed-in-qcombobox-descendant-editor-in-delegate) that reminded me of your problem.

Interesting. I think it's a bug in the QtColorComboBox class. I created my own colorcombobox that behaves identically to QtColorComboBox but doesn't exhibit the crash.

norobro
22nd May 2010, 05:54
After seeing that post I played around with your example a little and ended up adding the following code to the Delegate class to solve the segfault problem:
bool eventFilter(QObject *obj, QEvent *event){
Q_UNUSED(obj);
if(event->type()==QEvent::FocusOut) return true;
return false;
}
How did you handle retaining the custom colors when the delegate goes out of scope?