You are not logged in.

1

Thursday, March 27th 2008, 3:51pm

GUI crash

Hello, I have a little problem. Im developing a chat client by using third-part lib. When it gets user list (it sends every info for every user), it updates the gui so fast that makes it crashes.
Can you help me please?

Thank you very much

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

2

Thursday, March 27th 2008, 4:47pm

Hi,

Are you updating the GUI on a working Thread?
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

3

Thursday, March 27th 2008, 4:55pm

Thank you for your answer :) But wot do u mean?

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

4

Thursday, March 27th 2008, 5:11pm

Hi,

Have you created a QThread that takes the user info and modifies the GUI?

The GUI widgets only can be modified on the Main Thread, so you will have to emit the data to a slot on the Main Thread and then update the GUI there.
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

5

Thursday, March 27th 2008, 5:55pm

Hello, I tried your solution and its very interesting :P Now the program emits a signal when new user comes and a slot manages it. But it doesn't update info and it says:

Source code

1
2
3
4
5
6
QObject::connect: Cannot queue arguments of type 'QTextCharFormat'
(Make sure 'QTextCharFormat' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QTextCursor'
(Make sure 'QTextCursor' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QMap<QString,QString>&'
(Make sure 'QMap<QString,QString>&' is registered using qRegisterMetaType().)


QMap object is used to store user information. Thx for your help :)

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

6

Thursday, March 27th 2008, 6:06pm

Hi,

So you are using a Thread right?

The other problem is that is not possible to send objects by signal slots mechanism if them are not registered using something like this

Source code

1
int iIDRYourClass = qRegisterMetaType<YourClass>("YourClass");


Then you can send them by signals and recive them on slots.
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

7

Thursday, March 27th 2008, 7:22pm

Sorry I didnt reply to your last question. I'm not using QThread that takes care of the user info and modifies the GUI. Which is the best solution? :D

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

8

Thursday, March 27th 2008, 7:50pm

Hi,

So, if you are not creating any thread, are you sure that the application is crashing because you update the GUI so fast?
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

9

Friday, March 28th 2008, 10:29am

Hello ^NyAw^,

I think so. It happens when the method emits around 10000 signals per second connected to one receiver. Here the backtrace:

Source code

1
2
3
4
5
6
7
8
9
10
11
Program received signal SIGSEGV, Segmentation fault. 
0xb78942e3 in ?? () from /usr/lib/qt4/libQtGui.so.4 
(gdb) where 
#0  0xb78942e3 in ?? () from /usr/lib/qt4/libQtGui.so.4 
#1  0xb7894b61 in QRegion::unite () from /usr/lib/qt4/libQtGui.so.4 
#2  0xb7894e33 in QRegion::operator+= () from /usr/lib/qt4/libQtGui.so.4 
#3  0xb7897ace in ?? () from /usr/lib/qt4/libQtGui.so.4 
#4  0xb7897ce4 in ?? () from /usr/lib/qt4/libQtGui.so.4 
#5  0xb7897e00 in QWidget::update () from /usr/lib/qt4/libQtGui.so.4 
#6  0xb7a59fac in ?? () from /usr/lib/qt4/libQtGui.so.4 
#7  0xb7a5d410 in QLabel::setText () from /usr/lib/qt4/libQtGui.so.4 


I think I should use queue signals but as u said I have to register the object QHash<QString, QString> since it doesn't know what it is. I tried to use qRegisterMetaType(userHash) but it said:

Source code

1
no matching function for call to 'qRegisterMetaType(QHash<QString, QString>&)'

and header QMetaType is included. Do you think this is the right way?

Thank you for your great help ;)

This post has been edited 2 times, last edit by "foxyproxy" (Mar 28th 2008, 10:33am)


^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

10

Friday, March 28th 2008, 12:54pm

Hi,

I don't really know how to do this, but try creating your own class derived from "QHash<QString, QString>" named as "myHashClass" and then call

Source code

1
qRegisterMetaType(myHashClass); //Without "&" !
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

11

Friday, March 28th 2008, 5:24pm

Bah still cant figure it out :(

Source code

1
2
QObject::connect: Cannot queue arguments of type 'myHashClass'
(Make sure 'myHashClass' is registered using qRegisterMetaType().)


It gives me always the same error and I use Q_DECLARE_METATYPE macro to register it (it's the same of qRegisterMetaType)

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

12

Friday, March 28th 2008, 5:50pm

Hi,

If you read about registering meta type you will find that the class needs copy constructor, ...

But if you are donig the work on the main thread you don't need to emit to a slot to update data. Don't really know how to solve your problem, sorry.
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

13

Saturday, March 29th 2008, 6:03pm

Hello NyAw,
I would thank you for your help!
I have fixed my problem :) When i connect a signal with custom data types and it starts passing this custom data across threads, it complains it isnt registered. In my case I have done:

Source code

1
typedef QMap<QString, QString> myMap;


and then before connecting the signal:

Source code

1
qRegisterMetaType<myMap>("myMap&");

^NyAw^

Trainee

  • "^NyAw^" is male

Posts: 135

Location: Sta.Eugenia de Berga (Vic - Barcelona - Catalunya)

Occupation: Software Programmer

  • Send private message

14

Monday, March 31st 2008, 9:52am

Hi,

So, It's working now? Is not crashing on fast GUI updating?
Òscar Llarch i Galán

(\__/)
(O.o )
(> < )

15

Monday, March 31st 2008, 12:22pm

Yea ;) Is it possible to mark this post as SOLVED please? thank you