Padre Single Instance now correctly foregrounds on Win32

Alias on 2009-06-05T15:40:00

Of course, I'm not at all proud of what I had to do to get there, but after around 20 minutes per line of code trawling through MSDN, I finally managed to find a combination that works.

The single instance server now immediately sends the PID on connect (leading space padded to specifically 10 bytes) and the the client does the following.

my $pid  = '';
my $read = $socket->sysread( $pid, 10 );
if ( defined $read and $read = 10 ) {
	# Got the single instance PID
	$pid =~ s/\s+\s//;
	if ( Padre::Util::WIN32 ) {
		require Win32::API;
		Win32::API->new(
			'User32.dll',
			'AllowSetForegroundWindow',
			'N', 'L',
		)->Call($pid);
	}
}


Ummmm...

Ron Savage on 2009-06-06T01:57:58

Pretty please tell me you /really/ used '==' and not '=' in that 'if' statement.

Re:Ummmm...

DiamondInTheRough on 2009-06-07T04:12:46

Unfortunately, not.

http://padre.perlide.org/changeset?new=5092%40trunk&old=5091%40trunk

But it's only on svn at the moment, not released, so it should be easy for a committer to add the character.

Re:Ummmm...

gabor on 2009-06-07T04:23:00

fixed, thanks

Re:Ummmm...

Alias on 2009-06-09T00:45:22

I gotta say, one of my favourite things about the Padre development team is that I can add a bug to Padre before I go to bed and there's a good chance that by the time I wake up, it's gone. :)

Re:Ummmm...

Alias on 2009-06-07T07:28:11

oopsi