Project

General

Profile

Segmentation fault about WMessageBox...

Added by Richard Li over 11 years ago

Wt's version is 3.3.1

I use it like these:

1.I create a modal WMessageBox box in WApplication's thread, implemented like the static method WMessageBox::show().

then I connect a slot to a signal:

the slot code:

void slot
{
box.setText("1234567");
}

the signal is emit from a thread out of the WApplication.

When I catch the signal, segmentation fault.

2.I change the slot:

void slot
{
box.accept();
}


then connect a new slot2 to box.finished()

box.finished().connected(boost::bind(&class::slot2, class));

void slot2
{
WMessageBox::show(...);
}

segmentation fault.

I can make sure the code has went into the slot2.


Replies (6)

RE: Segmentation fault about WMessageBox... - Added by Wim Dumon over 11 years ago

Do you have a stack trace of the segmentation fault?

What is your boost version? Using boost.signals or boost.signals2?

Wim.

RE: Segmentation fault about WMessageBox... - Added by Richard Li over 11 years ago

Well, I can't see the stack in arm....the valgrind worked incorrect....

But there is another phenomenon:

1.In the first test:

In the slot, I use another code

std::cout << "-----------------" << std::endl;

instead of box.setText();

It will be worked well.

2.In the second test:

In the slot2, I use another code

std::cout << "-----------------" << std::endl;

instead of WMessageBox::show(...);

It will be worked well.

It seems that if I want control the box in the slot, only accept() method can correctly work.

RE: Segmentation fault about WMessageBox... - Added by Koen Deforche over 11 years ago

Hey Richard,

Can you post a complete self-contained test case? This will help us in either point out what you're doing wrong or reproduce the problem ourselves.

Regards,

koen

RE: Segmentation fault about WMessageBox... - Added by Richard Li over 11 years ago

I thought I have found what causes this problem...

In my problem, I have at least two thread use the slot or slot2.

When I use the boost::signal,the slot is a callback function and actually running in the thread out of the WApplication which have no WApplication's

environment. So that if I change the Wt's object in the slot, segmentation fault occured.

RE: Segmentation fault about WMessageBox... - Added by Koen Deforche over 11 years ago

Hey,

You can't just access Wt objects from different threads. If you want that, you need to read up on Wt's WApplication::UpdateLock

Regards,

koen

    (1-6/6)