Re: ShowWindow() Not Displaying Consistently
Re: ShowWindow() Not Displaying Consistently
- Subject: Re: ShowWindow() Not Displaying Consistently
- From: "devdrvr.net Multi-Platform SW" <email@hidden>
- Date: Tue, 12 Nov 2002 03:32:43 -0800
Found the answer to my own question regarding the below Carbon post,
11/9/02. I see why no one else got back to me. Thought I'd share in case
anyone else runs into something similar. What is wrong with the below is
calls like SetPortWindowPort are not thread safe. I mention below that
there are 26 MacOS X threads running for this movie editing application as
the main window comes up when the Draw() fragment blits to the pixmap.
Sporadic behavior ensues while drawing so spot rects don't get filled.
My window not appearing sometimes is due to NewCWindow and CreateNewWindow
not being thread safe. And I thought about making my window from a nib as
as the answer (to the latter) with Cocoa but CreateWindowFromNIB is not
thread safe either. The correct answer for C++ X threads is a mutex that
lets no threads lock while my non-thread safe calls gets done, then free the
reservation object. I'm working on putting that into the code. In the
meantime I've found workarounds that make both cases work so we can give a
solid demo of the whole thing running Fri.
--Perry
========
01 (530) 400-5692 [Davis, CA USA]
mailto:email@hidden
http://www.devdrvr.net/PerryCard.html
ftp://www.devdrvr.net/
On 11/9/02 6:29 PM, "devdrvr.net Multi-Platform SW" <email@hidden>
wrote:
>
My Show() looks like the following:
>
...
>
SelectWindow(fWindowRef);
>
ShowWindow(fWindowRef);
>
SetPortWindowPort(fWindowRef);
>
>
Got a digital movie editing app project I'm working on and we're getting
>
close to alpha. There is a weird Carbon (probably my code) drawing bug with
>
my main window. It is based on a new GWorld offscreen pixmap that I doctor
>
up for the effects and funky buttons. My problem is that the window
>
sometimes doesn't fully draw. Sometimes it does draw on 1st launch and
>
other times different random parts don't get updated. These parts tend to
>
be in the bottom half of the window.
>
>
Draw():
>
...
>
if (fWindowRef && fGWorld)
>
{
>
GetPort(&pCGrafSave);
>
SetPortWindowPort(fWindowRef);
>
>
src.left = rect.left;
>
src.top = rect.top;
>
src.right = rect.right;
>
src.bottom = rect.bottom;
>
>
if (LockPixels(GetGWorldPixMap(fGWorld))) {
>
if (GetPortBitMapForCopyBits(GetWindowPort(fWindowRef)))
>
::CopyBits (GetPortBitMapForCopyBits(fGWorld),
>
GetPortBitMapForCopyBits(GetWindowPort(fWindowRef)),
>
&src,
>
&src,
>
srcCopy+ditherCopy,
>
nil);
>
UnlockPixels(GetGWorldPixMap(fGWorld));
>
}
>
SetPort(pCGrafSave);
>
}
>
>
For alpha is there some way that I'm not thinking of to force the window to
>
completely re-draw. I've tried inval rect of the entire window bounds and
>
that doesn't always work. Maybe it is my event loop locally. Because if I
>
move something over the window and then away that area updates fine. So my
>
CopyBits of the GWorld is probably correct. Also I draw 3 other simpler
>
windows based on the same exact code and they never seem to have a problem.
>
Is there a WindowServer-ism I'm missing? Of course this app is kind of
>
complicated with 26 C++ spawned threads running at the same time so it is
>
quite possibly some other interaction bug I need to figure out between the
>
threads. But at the point of failure I don't have any effects running and a
>
movie is not loaded it is just an interesting looking offscreen GWorld
>
pixmap blit-ted to the window real estate (with another set of code that
>
maps controls over the images).
>
>
--Perry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.