Bug in KAction::initPrivate

Ellis Whitehead ellis at kde.org
Tue Sep 24 15:50:31 BST 2002


Hi Michael,

This was added for the kdegames modules.  They use names like:
	"move to pile {1}" ... "move to pile {<x>}"
and attach to the same slot, sparing the developer writing <x> wrapper slots.

If you don't pass a slot which takes a single int parameter, this condition 
will be skipped, and the normal connection will be made.  Otherwise, you can 
let the action know what the value of that parameter should be by enclosing 
an integer in braces.

Cheers,
Ellis

On Tuesday 24 September 2002 16:26, Michael Brade wrote:
> Hi,
>
> I tried to fix the broken "To Desktop" menu in KNotes and found the cause
> in the following code snippet from kaction.cpp, line 308:
>
>     if ( receiver && slot ) {
>         d->m_connected = true;
>         if ( QString(slot).find( QRegExp("\\(\\s*int\\s*\\)") ) >= 0 ) {
>
> upto here it's fine
>
>             QRegExp rxVal("\\{(.+)\\}");
>
> this is what I don't understand - this regexp makes no sense to me and I
> have no idea what rxVal means.
>
>             rxVal.setMinimal( true );
>             if ( rxVal.search( name() ) >= 0 ) {
>
> because of that strange regexp this is always -1. I don't think there are
> action names that contain "{" and "}". Not even KNotes to_desktop action ;)
>
>                 d->m_slotParam = rxVal.cap(1).toInt();
>                 connect( this, SIGNAL( activated( int ) ), receiver, slot
> );
>
> and thus this *important* connection is never made.
>
>             }
>         }
>         else
>             connect( this, SIGNAL( activated() ), receiver, slot );
>     }
>
> Any ideas about this code or how to fix it? Ellis? I'd just remove the
> strange regexp and the search() call.





More information about the kde-core-devel mailing list