Project

General

Profile

Signals and multiple slots

Added by S van der Hoest over 12 years ago

Hi,

I'm having an issue handling e.g. the 'clicked' of a WPushButton.

Here is an example, in which I have two buttons A & B, which should 'toggle':

WPushButton* btnA = new WPushButton("button A", this);

WPushButton* btnB = new WPushButton("button B", this);

btnB->disable();

// make only B enabled

btnA->clicked().connect( btnA, &WPushButton::disable );

btnA->clicked().connect( btnB, &WPushButton::enable );

// make only A enabled

btnB->clicked().connect( btnB, &WPushButton::disable );

btnB->clicked().connect( btnA, &WPushButton::enable );

What I'm seeing though is:

- start: A is enabled, B is disabled (=OK)

- click A: A gets disabled, B gets enabled (=OK)

- click B: noting happens (=NOT OK)

  • press F5: A gets enabled, B gets disabled (=OK but too late) (Wt is configured that reload does not start a new session)

What I've tried:

- connect 1 'normal' function to the buttons and update both A & B from there: works OK

  • connect 2 'normal' functions to the buttons , one to update A, one to update B: works OK

Question 1: Is something wrong here, or am I doing something wrong?

As I don't understand e.g. this example, it keeps me from 'relying' the signal/slot mechanism with multiple slots.

Question 2: I noticed that the order how slots are handled is LIFO order (from WSignal, connected 'at_front'),

while boost uses 'FIFO' by default (http://www.boost.org/doc/libs/1_49_0/doc/html/signals/tutorial.html).

Why this difference?

Situation:

- Wt: 3.2.1, running with wthhtp

- Boost: 1.49

  • Browsers: IE8, Chrome 19.0.1084.56

Kind regards,

Sebastiaan


Replies (1)

RE: Signals and multiple slots - Added by Wim Dumon over 12 years ago

Sebastiaan,

That is a bug in Wt. Koen will take a look at it (issue #1331)

Wim.

    (1-1/1)