[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: InterProcess Comunication
From:       Adriaan de Groot <adridg () cs ! kun ! nl>
Date:       2003-07-07 22:32:58
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 08 July 2003 02:51, Ryan Bean wrote:
> I have a KApplication 'a' which forks a KApplication 'b' using KProcess
> and both are registered using the dcopClient() method from KProcess.
>  'a' needs to send data to 'b' right at the start of 'b'.  I need a way
> to have 'a' wait on some signal from 'b', and some way for 'b' to signal
> 'a'.  I've tried many many ways.  I got a responce from someone
> subgesting that I have 'b' notify 'a' via dcop.  

If you're using DCOP, then surely you have a .kidl file somewhere? One that 
says something like

class AppADCOP : virtual public DCOPObject
{
K_DCOP
public:
	virtual ASYNC applicationBIsReady() = 0L;
} ;

and one of the objects in your Application A - like, say, the main window - 
inherits multiply from KMainWindow and AppADCOP, implementing the functions, 
for instance

/* virtual */ ASYNC /* that's void, really */ 
AppAImplementation::applicationBIsReady()
{
	// Allow 10 ms to give B time to recover
	QTimer::singleShot(10,this,SLOT(sendDataToB()));
}

> The only method I see
> with dcop is a send function which allows data to be sent, but the data
> will not arrive if the receiver is not ready, how can I know in 'b' that

Sure, so KProcess::start() your application B, and then return to the main 
event loop. You don't have to sit around waiting anxiously for B to start. 
Get on with your life. A is _always_ ready to receive the 
applicationBIsReady() DCOP message.

> 'a' got it, and that 'a' is even ready, and how can I know the same from
> 'a' to 'b'?  The send function for a dcopClient has a bool return,
> SAYING it returns success on send.  But it returns true even when 'b'
> was not ready, and my app gets no message.  If I use a KMessageBox in
> 'a' to manually wait for 'b' to start, it works, if I use a sleep, 'a'
> stalls until 'b' is complete.

Well, no duh, because sleep() blocks everything, and is a bad thing in GUI 
apps (or server apps). Just go back to the main event loop. If you wait for 
events, they will come, even if it's XKillWindow.

Don't use send() for DCOP messages. Use the stub files that are generated from 
.kidl to do your calls. 

- -- 
pub  1024D/FEA2A3FE 2002-06-18 Adriaan de Groot <groot@kde.org>
     Key fingerprint = 934E 31AA 80A7 723F 54F9  50ED 76AC EE01 FEA2 A3FE
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE/CfUgdqzuAf6io/4RAjwgAJ9aDtVBgdYE8yjsIkQUKjMhn/MEowCdFT4+
xsdutzuhf6IMon4t8CywqO8=
=gkeX
-----END PGP SIGNATURE-----

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic