From: Riccardo Cohen on
Hi
I have a program that works on wxmac2,7 , but with 2,9 it displays the
following assertion : "Cannot nest wxDCs on the same window"

this happens when I do

wxClientDC *dc=new wxClientDC(diag);
dc->DrawRectangle(rec);
delete(dc);

inside a timer_wake event.
I do not understand exactly what it means. Is there something changed
from 2,7 to 2,9 on dc creation ?

Thanks for any info.

--
Tr�s cordialement,

Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av G�n�ral de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Robin Dunn on
Riccardo Cohen wrote:
> Hi
> I have a program that works on wxmac2,7 , but with 2,9 it displays the
> following assertion : "Cannot nest wxDCs on the same window"
>
> this happens when I do
>
> wxClientDC *dc=new wxClientDC(diag);
> dc->DrawRectangle(rec);
> delete(dc);
>
> inside a timer_wake event.
> I do not understand exactly what it means.

You can not have more than one wxDC active at the same time for the same
window. Somewhere you have another DC already using diag when the code
above is called.


> Is there something changed
> from 2,7 to 2,9 on dc creation ?

wxMac is now using the CoreGraphics APIs which have a few more
restrictions than what was being used before.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Stefan Csomor on
Hi
> On Mon, 01 Oct 2007 09:55:15 -0700 Robin Dunn <robin(a)alldunn.com> wrote:
>
> RD> Riccardo Cohen wrote:
> RD> > Hi
> RD> > I have a program that works on wxmac2,7 , but with 2,9 it displays the
> RD> > following assertion : "Cannot nest wxDCs on the same window"
> RD> >
> RD> > this happens when I do
> RD> >
> RD> > wxClientDC *dc=new wxClientDC(diag);
> RD> > dc->DrawRectangle(rec);
> RD> > delete(dc);
> RD> >
> RD> > inside a timer_wake event.
> RD> > I do not understand exactly what it means.
> RD>
> RD> You can not have more than one wxDC active at the same time for the same
> RD> window. Somewhere you have another DC already using diag when the code
> RD> above is called.
>
> This seems like a rather bad restriction. I wonder if we couldn't make
> all wxClientDC instances on the same window use the same underlying
> CGContext somehow. It could still result in problems with changing DC
> attributes but if we restored them carefully, it would allow something
> (common) like this:
>
I've tried this in earlier times, but I was not successful when another context for another wxWindow on the same toplevel window that was currently drawing was requested, but since now all code is Quartz only, I could try again.

Neverthelesss I really think that every drawing has to be moved to a OnPaint event, and the only reason to use a dc outside is for measuring purposes, which already can be done. It is the way the new drawing systems perform optimally, intermittent drawing leads to synchronization bottlenecks.

Best,

Stefan



---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Riccardo Cohen on
I agree and admit that it is the safiest way, but it is often easyer to
do a "draw now" under certain user action, rather than "change data"
then "refresh"...

For instance when a user select a zone, I have a mouse motion event, and
I want to draw a rectangle that follows the mouse to show the zone, I
can resize a rectangle object and then refresh, but it is easyer to call
drawrectangle() immediatly. The same for timer event : for blinking
objects I simpy change the color at each timer event and draw a little
point with this color.

My present problem is that I used this method quite often. Buf if quartz
does not allow it, I'll change my code.

By the way you spoke about measuring, it happens that in the destructor
of one of my windows, I have call some cleaning code that create a DC to
measure text size. This lead to an exception while in the window
destructor. Maybe you've got an idea for that point also.


Thanks for your great work anyway.

Stefan Csomor wrote:
> Hi
>> On Mon, 01 Oct 2007 09:55:15 -0700 Robin Dunn <robin(a)alldunn.com> wrote:
>>
>> RD> Riccardo Cohen wrote:
>> RD> > Hi
>> RD> > I have a program that works on wxmac2,7 , but with 2,9 it
>> displays the RD> > following assertion : "Cannot nest wxDCs on the
>> same window"
>> RD> > RD> > this happens when I do
>> RD> > RD> > wxClientDC *dc=new wxClientDC(diag);
>> RD> > dc->DrawRectangle(rec);
>> RD> > delete(dc);
>> RD> > RD> > inside a timer_wake event.
>> RD> > I do not understand exactly what it means.
>> RD> RD> You can not have more than one wxDC active at the same time
>> for the same RD> window. Somewhere you have another DC already using
>> diag when the code RD> above is called.
>>
>> This seems like a rather bad restriction. I wonder if we couldn't make
>> all wxClientDC instances on the same window use the same underlying
>> CGContext somehow. It could still result in problems with changing DC
>> attributes but if we restored them carefully, it would allow something
>> (common) like this:
>>
> I've tried this in earlier times, but I was not successful when another
> context for another wxWindow on the same toplevel window that was
> currently drawing was requested, but since now all code is Quartz only,
> I could try again.
>
> Neverthelesss I really think that every drawing has to be moved to a
> OnPaint event, and the only reason to use a dc outside is for measuring
> purposes, which already can be done. It is the way the new drawing
> systems perform optimally, intermittent drawing leads to synchronization
> bottlenecks.
>
> Best,
>
> Stefan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>
>

--
Tr�s cordialement,

Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av G�n�ral de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Riccardo Cohen on
Actually I found an unnecessary wxClientDC creation, I removed it and
all went all right. I changed my code to call some RefreshRect() instead
of drawing directly...
thanks


Riccardo Cohen wrote:
> I agree and admit that it is the safiest way, but it is often easyer to
> do a "draw now" under certain user action, rather than "change data"
> then "refresh"...
>
> For instance when a user select a zone, I have a mouse motion event, and
> I want to draw a rectangle that follows the mouse to show the zone, I
> can resize a rectangle object and then refresh, but it is easyer to call
> drawrectangle() immediatly. The same for timer event : for blinking
> objects I simpy change the color at each timer event and draw a little
> point with this color.
>
> My present problem is that I used this method quite often. Buf if quartz
> does not allow it, I'll change my code.
>
> By the way you spoke about measuring, it happens that in the destructor
> of one of my windows, I have call some cleaning code that create a DC to
> measure text size. This lead to an exception while in the window
> destructor. Maybe you've got an idea for that point also.
>
>
> Thanks for your great work anyway.
>
> Stefan Csomor wrote:
>> Hi
>>> On Mon, 01 Oct 2007 09:55:15 -0700 Robin Dunn <robin(a)alldunn.com> wrote:
>>>
>>> RD> Riccardo Cohen wrote:
>>> RD> > Hi
>>> RD> > I have a program that works on wxmac2,7 , but with 2,9 it
>>> displays the RD> > following assertion : "Cannot nest wxDCs on the
>>> same window"
>>> RD> > RD> > this happens when I do
>>> RD> > RD> > wxClientDC *dc=new wxClientDC(diag);
>>> RD> > dc->DrawRectangle(rec);
>>> RD> > delete(dc);
>>> RD> > RD> > inside a timer_wake event.
>>> RD> > I do not understand exactly what it means.
>>> RD> RD> You can not have more than one wxDC active at the same time
>>> for the same RD> window. Somewhere you have another DC already using
>>> diag when the code RD> above is called.
>>>
>>> This seems like a rather bad restriction. I wonder if we couldn't make
>>> all wxClientDC instances on the same window use the same underlying
>>> CGContext somehow. It could still result in problems with changing DC
>>> attributes but if we restored them carefully, it would allow something
>>> (common) like this:
>>>
>> I've tried this in earlier times, but I was not successful when
>> another context for another wxWindow on the same toplevel window that
>> was currently drawing was requested, but since now all code is Quartz
>> only, I could try again.
>>
>> Neverthelesss I really think that every drawing has to be moved to a
>> OnPaint event, and the only reason to use a dc outside is for
>> measuring purposes, which already can be done. It is the way the new
>> drawing systems perform optimally, intermittent drawing leads to
>> synchronization bottlenecks.
>>
>> Best,
>>
>> Stefan
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
>> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
>>
>>
>

--
Tr�s cordialement,

Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av G�n�ral de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org