PDA

View Full Version : QGraphicsItem->type() crush



gilamran
4th December 2010, 20:32
hi,
I'm trying to go over all the Graphics Scene's items, I'm printing out their x and y. and it's all working well... but when I call the type() function it's crushing...

I'm not the one who implemented the graphics item, I don't even have the code...
I just have a scene and I want to understand its structure...

I know about at least one item that the type() call is working without crushing...
and it returns different number each run... last time it was 2425260... that's quite huge... isn't it?
The UserType is 65536. so 2425260 isn't realy a number I can consider true... even more when this numbers change each run...

THANKS for any clue
Gil.

ChrisW67
4th December 2010, 21:06
2425260 is a perfectly good type() value, so that in itself is not the problem. If the program is crashing when you access a QGraphicsItem then how are you getting the type() value? You are probably using a null or otherwise invalid pointer that you think points to a QGraphicsItem.

gilamran
5th December 2010, 08:22
The list of QGraphicsItems is taken from QGraphicsScene.items().
The list contains about 200 items. all of them have a valid x and y...

When I try to access the first item's type() function. I crush.
When I try to access some other item's type() function I get different number each run.

Now getting different number each run points to the fact that something in wrong. isn't it hard-coded into the class?

What can I do?
Gil.

tbscope
5th December 2010, 09:02
Provide a working, compilable and minimal example demonstrating the problem.

Does this happen with a custom graphics item?
The problem might be in your graphics item subclass if you're trying to call a parent or other object that is not a valid pointer.

The type of a specific item should always be the same. Since the numbers jump randomly, that too is a sign of "corrupted" memory (as in, accessing memory you shouldn't access which happens with incorrect use of pointers).

wysota
5th December 2010, 10:58
It could be that the type() method is incorrectly reimplemented in a custom subclass of QGraphicsItem and returns some bogus value. One needs to take a look at the source code of custom items used in the scene.

gilamran
6th December 2010, 13:59
My code is a dll that I inject into a running QT application.
Currently everything works (Like getting the QWidgets, QGraphicView, Item's x and y etc) except for that type() that's crushing the main QT application.

Any idea? say anything you think might cause the problem, I'll check it.

wysota
6th December 2010, 14:29
Are you another person trying to hack into the poker software?

gilamran
6th December 2010, 14:31
hack sounds bad... I'm writing a software that will help users with their poker game.
Yeap me too... anyone else?

tbscope
7th December 2010, 04:37
Yeap me too... anyone else?
Yes, every script kiddy that thinks he can get rich by doing so.

gilamran
7th December 2010, 07:34
hoo what a lovely person.
I'm a software developer for 15 years now, poker is one of my biggest hobbies, and I know all the software for poker out there, and I'm missing many things...
Thought that it would be great to write something that will help me improve my game.

Thanks anyways

wysota
7th December 2010, 11:24
hoo what a lovely person.
I'm a software developer for 15 years now, poker is one of my biggest hobbies, and I know all the software for poker out there, and I'm missing many things...
Thought that it would be great to write something that will help me improve my game.
Did you check if you are not in violation with the software licence before trying to hack into the system?