[Kde-games-devel] KPat/Freecell broken?

Andreas Pakulat apaku at gmx.de
Mon Dec 14 22:19:31 CET 2009


On 14.12.09 21:07:30, Andreas Pakulat wrote:
> On 14.12.09 12:50:24, Parker Coates wrote:
> > Ah. That makes perfect sense. For 4.4 KPat is much smarter at
> > detecting when an animation is in progress, so lots of actions are
> > prevented until the animation is complete to keep things nicely
> > sequenced. Freecell was cheating and moving on as soon as the first
> > card finished animating, but checks recently added elsewhere must have
> > been preventing it. Waiting for the last card makes sense.
> > 
> > Fortunately there's an even cleaner solution. CardDeck now has a
> > cardAnimationsDone() signal, so as soon as I get a chance, I'll modify
> > this logic to make use of that instead of manually connecting to the
> > animationStopped() signal of individual cards.
> 
> That might actually solve the spider problem. I've tried some debugging
> and for some (unfortunately unknown reason) the bookkeeping of
> carddeck.cpp m_cardsWaitedFor gets out of sync with reality. Thats why
> mousePressEvent then ignores all subsequent mouse events, the
> m_cardsWaitedFor is not 0 once the run is moved to the bottom-left
> stack.
> 
> I also saw that this only happens when you manually complete a run, if
> you complete a run by fetching another round of 10 cards from the
> right-hand stack and one of the cards completes a run this doesn't
> interrupt the flow!

I've tried to dig into this more, but I feel like I'm stuck as I don't
really have an idea how the animation of the cards is supposed to be
working. It seems this is a bit of a timing issue as with all the debug
output I now had one case where the right order of things happened. My
last "non-working" debug output is attached along with the diff for
that.

The output suggests that there's 2 animations started for one of the
cards, without a stopAnimation. So the "simplest" fix was to check
m_animation inside Card::animate() and call stopAnimation if its != 0:

Index: card.cpp                                                                                                                                
===================================================================                                                                            
--- card.cpp    (revision 1062335)                                                                                                             
+++ card.cpp    (working copy)                                                                                                                 
@@ -218,6 +218,9 @@                                                                                                                           
                                                                                                                                               
 void Card::animate( QPointF pos2, qreal z2, qreal scale2, qreal
rotation2, bool faceup2, bool raised, int duration )                          
 {                                                                                                                                             
+    if( m_animation ) {                                                                                                                       
+        stopAnimation();                                                                                                                      
+    }                                                                                                                                         
     if ( duration <= 0 )                                                                                                                      
     {                                                                                                                                         
         setPos( pos2 );

I have no idea wether that change is correct, or wether one should try
to find why things aren't done in the "proper" order. But I'm not able
to do the latter anyway.

Andreas

-- 
Your talents will be recognized and suitably rewarded.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_spider.diff.bz2
Type: application/octet-stream
Size: 2383 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-games-devel/attachments/20091214/4a251f05/attachment.dll 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug_spider.output.bz2
Type: application/octet-stream
Size: 1127 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-games-devel/attachments/20091214/4a251f05/attachment-0001.dll 


More information about the kde-games-devel mailing list