On approximately 12/10/2003 5:45 AM, came the following characters from
the keyboard of Stephen Pick:

Hi.

OK. This is probably the strangest and most baffling fix I could have
stumbled on for this bug but here goes:

IO flushing.

Yep. If you flush *any* filehandle currently open for writing (by
whatever means you like) immediately after calling Win32::GUI::DoEvents,
you don't get repeated messages. Flushing in the actual DoEvents C code
doesnt work, the flush must be done in Perl, and outside of any event
handler. You can even flush a filehandle you just open()ed for writing.
Don't ask me.

This works (uses IO::Handle to flush stdout):

use IO::Handle;
my $io = new_from_fd IO::Handle(1,">");
while(1) {
        Win32::GUI::DoEvents;
        $io->flush();
}

As does this (uses print to flush):

while(1) {
        Win32::GUI::DoEvents;
        print "\n";
}

And this (uses print and autoflush to prevent filling the console with
emptiness):

$| = 1;
while(1) {
        Win32::GUI::DoEvents;
        print " \010";
}

Now if anyone can explain away THIS behaviour I'll be really impressed.

So will I !!!!  But at least we now have a clue of sorts.

I did try to dig through perl's internals to find out exactly WHAT it
does on flush (I suspect it's slightly more than just an fflush() ).
Could this possibly be anything to do with the "<DATA> line xxx" i see
in every console warning message created by Win32::GUI ?? What *is* that
all about?

What THAT is all about is a missing close in Win32::API::Type.pm ....

Here's the text of the message I sent to Aldo on 11/21/2003 when I discovered the problem: Sorry about the formatting below.

Hi Aldo,

In the file Win32/API/Type.pm the INIT section fails to close the DATA handle, causing all error messages 
in scripts that "use Win32::API" to have an extra "<DATA> line 164" at the end 
of the location reference.

This is confusing, because people don't expect modules to leave files open 
during a use, and especially if they have a data section of their own that they 
didn't think they'd opened yet.... or thought they had closed already...

A line containing

close( DATA );

just before the last } of the INIT section in that file seems to cure the problem.

--
Glenn -- http://nevcal.com/
===========================
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick.  It's ridiculous.
-- Bill Gates

And here is why it is ridiculous:
The division that includes Windows posted an operating profit of $2.26 billion on revenue of $2.81 billion. --from Reuters via http://biz.yahoo.com/rc/031113/tech_microsoft_msn_1.html

So that's profit of over 400% of investment... with a bit more investment in Windows technology, particularly in the area of reliability, the profit percentage might go down, but so might the bugs and security problems? Seems like it would be a reasonable tradeoff. WalMart earnings are 3.4% of investment.


Reply via email to