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

Qt-jambi-interest Archive, October 2006
JVM Crash on treeview.


Message 1 in thread

Hi,
I followed one of the Qt/C++ tutorials and created a simple tree model for
tree view. The attached code crashes JVM when I try to expand an item with
children. Java reports that there is segmentation fault in Qt library. I
cannot understand if there is anything wrong with my code.
Another question I have is why createIndex(int, int, int) takes the last
parameter ( an internalId as I understand ) as int but not
long, where in QModelIndex has internalId as qint64?

Here is the console output when JVM crashes:
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0xa98ed53d, pid=5594, tid=3085409120
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# C [libQtGui.so.4+0x45e53d]
_ZNK9QTreeView16indexRowSizeHintERK11QModelIndex+0x36d
#
# An error report file with more information is saved as hs_err_pid5594.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

An error report file is attached as well.
Thanks.
-- 
 [ signature omitted ] 

Attachment: TreeView.tar.gz
Description: GNU Zip compressed data


Message 2 in thread

Sergejs Melderis wrote:
> Hi,
> I followed one of the Qt/C++ tutorials and created a simple tree model for
> tree view. The attached code crashes JVM when I try to expand an item with
> children. Java reports that there is segmentation fault in Qt library. I
> cannot understand if there is anything wrong with my code.
> Another question I have is why createIndex(int, int, int) takes the last
> parameter ( an internalId as I understand ) as int but not
> long, where in QModelIndex has internalId as qint64?

Hi Sergejs,

I'll look more into the segfault and the createIndex detail tomorrow, 
but is there any particular reason why you don't want to use the item 
based API. Judging from the code this is what you trying to acheive in 
the first place.

See:
http://doc.trolltech.com/4.1/qtreewidget

for details.

best regards,
Gunnar


Message 3 in thread

Sergejs Melderis wrote:
> Hi,
> I followed one of the Qt/C++ tutorials and created a simple tree model for
> tree view. The attached code crashes JVM when I try to expand an item with
> children. Java reports that there is segmentation fault in Qt library. I
> cannot understand if there is anything wrong with my code.

Hi Sergejs,

I had a bit closer look at the code now and when I ran it against a 
debug version of Qt I see that you are triggering an assert:

ASSERT failure in QAbstractItemView::setModel: "The parent of a top 
level index should be invalid", file itemviews\qabstractitemview.cpp, 
line 489

This is caused by the lines:

		if(parentItem == rootItem)
			return rootModelIndex;

in the parent function(). The root item should not have a parent, so the 
correct value to return here should be "null".

---

> Another question I have is why createIndex(int, int, int) takes the
> last parameter ( an internalId as I understand ) as int but not long,
> where in QModelIndex has internalId as qint64?

This is a glitch in how the API is mapped from C++ to Java. The Item 
View's API in Jambi still needs a bit of tweaking ;-)

best regards,
Gunnar





Message 4 in thread

OK, but should an error like that really /crash the JVM/???

That sounds a bit overreactive :-)

Just my 2c,

M

-----Original Message-----
From: Gunnar Sletta [mailto:gunnar@xxxxxxxxxxxxx]
Sent: Fri 10/6/2006 11:09 AM
To: Sergejs Melderis
Cc: qt-jambi-interest@xxxxxxxxxxxxx
Subject: Re: JVM Crash on treeview.
 
Sergejs Melderis wrote:
> Hi,
> I followed one of the Qt/C++ tutorials and created a simple tree model for
> tree view. The attached code crashes JVM when I try to expand an item with
> children. Java reports that there is segmentation fault in Qt library. I
> cannot understand if there is anything wrong with my code.

Hi Sergejs,

I had a bit closer look at the code now and when I ran it against a 
debug version of Qt I see that you are triggering an assert:

ASSERT failure in QAbstractItemView::setModel: "The parent of a top 
level index should be invalid", file itemviews\qabstractitemview.cpp, 
line 489

This is caused by the lines:

		if(parentItem == rootItem)
			return rootModelIndex;

in the parent function(). The root item should not have a parent, so the 
correct value to return here should be "null".

---

> Another question I have is why createIndex(int, int, int) takes the
> last parameter ( an internalId as I understand ) as int but not long,
> where in QModelIndex has internalId as qint64?

This is a glitch in how the API is mapped from C++ to Java. The Item 
View's API in Jambi still needs a bit of tweaking ;-)

best regards,
Gunnar




Message 5 in thread

Matthias Nott wrote:
> OK, but should an error like that really /crash the JVM/???
> 
> That sounds a bit overreactive :-)

Hi Matthias,

We have stated previously that all VM crashes are things we will not 
have in the final version. We should definitly not crash. This is why I put:

 > This is a glitch in how the API is mapped from C++ to Java. The Item
 > View's API in Jambi still needs a bit of tweaking ;-)

at the end, but it wasn't explicit. The item views API has several 
pitfalls right now, and we will address those so that these kinds 
mistakes are not possible.

Keep the good feedback coming ;-)

best regards,
Gunnar