[Kde-games-devel] KMahjongg frameworks branch

Frederik Schwarzer schwarzer at kde.org
Wed Nov 18 13:11:45 UTC 2015


Am Mittwoch, 18. November 2015, 16:46:24 schrieb Ian Wadham:
> Hi Frederik,
> 
> On 18/11/2015, at 10:13 AM, Ian Wadham wrote:
> > On 18/11/2015, at 10:06 AM, Frederik Schwarzer wrote:
> >> Ok, first stumbling block.
> >> While porting to the newer connect() syntax, some calls in
> >> GameView
> >> give me compile errors and I do not see the problem.
> >> 
> >> diff --git a/GameView.cpp b/GameView.cpp
> >> 
> >>    // Connections
> >> 
> >> -    connect(scene(), SIGNAL(selectionChanged()), this,
> >> SLOT(selectionChanged()));
> >> +    connect(scene, &GameScene::selectionChanged, this,
> >> &GameView::selectionChanged);
> > 
> > Do you still need the full signature? 
> > &GameScene::selectionChanged()?
> No (https://wiki.qt.io/New_Signal_Slot_Syntax), but I think you
> still need scene(). It is a function returning a pointer to the
> GameScene object.  See GameView.h. So the following should compile
> OK with Qt5…
>     connect(scene(), &GameScene::selectionChanged, this,
>     &GameView::selectionChanged);

You are right. And if it had only been calls with "scene", I might 
have noticed it but there were other calls as well ... where I forgot 
commas. All in one class so I was suspicious about the class itself 
and not the individual calls. :)
Now it compiles again. Thanks.

> Is there any real need to change this syntax? Apparently the old
> syntax is supported by Qt5.

KMahjongg was ported to the new syntax, so I did not want to have both 
versions mixed in one code base.

> Also I am worried that, in old code
> such as most KDE Games, signals with parameters might go wrong and
> automatic disconnects might fail when an object is destroyed.

Hmm, are there known problems? I just assumed, that whatever parameter 
combination was possible before would be caught by the new syntax 
automatically. It was possible for the sender to have more parameters 
than the receiver but the receiver could obly get the parameters in 
the same order. Is this not implicitly working with the new syntax?

To be honest, I do not know what happens with connects from or to 
objects, if the object is destroyed with neither old nor new syntax, 
so I cannot comment on that unless I get to read something more in 
that direction.

Regards
Frederik


More information about the kde-games-devel mailing list