Found the reason for #103713

Pascal Létourneau pletourn at globetrotter.net
Sun May 15 18:10:58 BST 2005


On May 15, 2005 12:37, Michael Brade wrote:
> Hi,
>
> 4 weeks ago I posted a question of how to debug this report, but despite
> all your great tips I gave up --- even backtraces didn't help me. Today I
> had an idea, and tried again successfully. The KToolBarButton class is the
> culprit!
>
> In KToolBarButton::mouseReleaseEvent the buttonClicked is emitted, which
> calls the correct slot in KNotes. However, it also calls
> QToolButton::mouseReleaseEvent, which in turn emits clicked(). Now
> KToolBarButton connects this signal so KToolBarButton::slotClicked() and in
> this slot it emits buttonClicked _again_, but only if the button's
> parent->rect() contains the button itself!
>
> First of all, I don't understand why this has to be so. Any ideas? The
> comment says something about an extension popup menu. What's that?
When the toolbar is full, an extra button appear at the end of it. When 
pressed, the extension menu is shown.
This hack was added to make the items inside the extension menu still send 
buttonClicked() (the first buttonClicked() is not send by them).
This patch should make the test a little more robust:

-  if ( d->m_parent && !d->m_parent->rect().contains( geometry() ) ) {
+  if ( d->m_parent && !d->m_parent->rect().contains( geometry().center() ) )

Does it solve your problem? 

> Here's the code:
>
>   // emit buttonClicked when the button was clicked while being in an
> extension popupmenu
>   if ( d->m_parent && !d->m_parent->rect().contains( geometry() ) ) {
>     ButtonState state = KApplication::keyboardMouseState();
>     if ( ( state & MouseButtonMask ) == NoButton )
>       state = ButtonState( LeftButton | state );
>     emit buttonClicked( d->m_id, state );
>
> Second, this is the reason KNotes works for me but not for others: with
> Keramik the buttons are 10x10 pixels, the toolbar has hight 16. However,
> with Plastik the buttons are bigger than the toolbar although I call
> setIconSize( 10 ). Thus the check in KToolBarButton::slotClicked() fails
> and buttonClicked is emitted again.
>
> Well, that's as far as I got. Is the code in KToolBarButton correct and I
> somehow have to fix the iconsizes in KNotes, or can we fix KToolBarButton
> as well?
>
> Cheers,

Pascal Létourneau







More information about the kde-core-devel mailing list