Quantcast

[OSX] using wxPaintDC without being in a native paint event

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[OSX] using wxPaintDC without being in a native paint event

Arthur Moraes Do Lago
Hi,

I'm new to wxWidgets, and I'm having an issue running the program in this repository, which is an updated version of this demo this demo for using wxWidgets with OpenCV.
It compiles normally, but when it starts to run, at the first Paint a window pops up with the following error:

../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef() != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a native paint event

Call stack:
[00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
[01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:14
[02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9
[05] wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const     appbase.cpp:61
[06] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const     appbase.cpp:62
[07] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)     event.cpp:139
[08] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)     event.cpp:99
[09] wxEvtHandler::TryHereOnly(wxEvent&)         event.cpp:158
[10] wxEvtHandler::TryBeforeAndHere(wxEvent&)     event.h:367
[11] wxEvtHandler::ProcessEventLocally(wxEvent&)     event.cpp:152
[12] wxEvtHandler::ProcessEvent(wxEvent&)        event.cpp:149
[13] wxEvtHandler::ProcessPendingEvents()        event.cpp:135
[14] wxAppConsoleBase::ProcessPendingEvents()     appbase.cpp:52
[15] wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int)     evtloop_cf.cpp:9
[16] wxCFEventLoop::OSXCommonModeObserverCallBack(__CFRunLoopObserver*, int, void*)     evtloop_cf.cpp:7
[17] __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
[18] __CFRunLoopDoObservers                  
[19] __CFRunLoopRun                          
[20] CFRunLoopRunSpecific                    
       
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.


If I click of [Cancel], the program continues normally and works as expected, but the terminal window keeps sending this alert on every Paint.

I looked up the error online and checked the docs, and most times, this error happens when a wxPaintDC is declared outside a Paint callback, but in this program, the callback [04] on the call stack is the following:

void CCamView::OnPaint(wxPaintEvent &event)
{
    wxPaintDC dc
(this); //The alert happens here, before Draw(dc) is called
   
Draw(dc);
}

 
So I don't think that's the case.

Has anyone ever encountered a similar issue? The closest I found was this question on stack overflow, but it still looks very different from mine, and I don't completely understand the answer.

Thank you all for your attention, Arthur.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [OSX] using wxPaintDC without being in a native paint event

oneeyeman
Hi,
Some basic questions:
1. Version of the library?
2. Version of the OS?
3. How did you build the library? 

Thank you. 



On Apr 2, 2017 9:26 PM, "Arthur Moraes Do Lago" <[hidden email]> wrote:
Hi,

I'm new to wxWidgets, and I'm having an issue running the program in this repository, which is an updated version of this demo this demo for using wxWidgets with OpenCV.
It compiles normally, but when it starts to run, at the first Paint a window pops up with the following error:

../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef() != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a native paint event

Call stack:
[00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
[01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:14
[02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9
[05] wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const     appbase.cpp:61
[06] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const     appbase.cpp:62
[07] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)     event.cpp:139
[08] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)     event.cpp:99
[09] wxEvtHandler::TryHereOnly(wxEvent&)         event.cpp:158
[10] wxEvtHandler::TryBeforeAndHere(wxEvent&)     event.h:367
[11] wxEvtHandler::ProcessEventLocally(wxEvent&)     event.cpp:152
[12] wxEvtHandler::ProcessEvent(wxEvent&)        event.cpp:149
[13] wxEvtHandler::ProcessPendingEvents()        event.cpp:135
[14] wxAppConsoleBase::ProcessPendingEvents()     appbase.cpp:52
[15] wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int)     evtloop_cf.cpp:9
[16] wxCFEventLoop::OSXCommonModeObserverCallBack(__CFRunLoopObserver*, int, void*)     evtloop_cf.cpp:7
[17] __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
[18] __CFRunLoopDoObservers                  
[19] __CFRunLoopRun                          
[20] CFRunLoopRunSpecific                    
       
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.


If I click of [Cancel], the program continues normally and works as expected, but the terminal window keeps sending this alert on every Paint.

I looked up the error online and checked the docs, and most times, this error happens when a wxPaintDC is declared outside a Paint callback, but in this program, the callback [04] on the call stack is the following:

void CCamView::OnPaint(wxPaintEvent &event)
{
    wxPaintDC dc
(this); //The alert happens here, before Draw(dc) is called
   
Draw(dc);
}

 
So I don't think that's the case.

Has anyone ever encountered a similar issue? The closest I found was this question on stack overflow, but it still looks very different from mine, and I don't completely understand the answer.

Thank you all for your attention, Arthur.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [OSX] using wxPaintDC without being in a native paint event

Arthur Moraes Do Lago
Hi,

1. I'm using wxWidgets 3.0.2
2. I'm on OSX 10.12.3(Sierra)
3. I compile using:
 ../configure --enable-debug --disable-mediactrl
and also, setting the follwing enviroment variables:
CXXFLAGS="-stdlib=libc++ -std=c++11" OBJCXXFLAGS="-stdlib=libc++ -std=c++11" LDFLAGS="-stdlib=libc++"

had to use --disable-mediactrl because some libraries, such as QuickTime.h were deprecated in OSX Sierra apparently, and the environment variables because some files like from some tr1 library were also missing, supposedly because the library was compiled using different version of stdlib.


Em domingo, 2 de abril de 2017 23:07:36 UTC-3, Igor Korot escreveu:
Hi,
Some basic questions:
1. Version of the library?
2. Version of the OS?
3. How did you build the library? 

Thank you. 



On Apr 2, 2017 9:26 PM, "Arthur Moraes Do Lago" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="IIAihbHJCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">arthurmo...@...> wrote:
Hi,

I'm new to wxWidgets, and I'm having an issue running the program in <a href="https://github.com/heinemml/wxOpenCV" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw&#39;;return true;">this repository, which is an updated version of this demo <a href="http://larryo.org/work/information/wxopencv/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw&#39;;return true;">this demo for using wxWidgets with OpenCV.
It compiles normally, but when it starts to run, at the first Paint a window pops up with the following error:

../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef() != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a native paint event

Call stack:
[00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
[01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:14
[02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9
[05] wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const     appbase.cpp:61
[06] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const     appbase.cpp:62
[07] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)     event.cpp:139
[08] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)     event.cpp:99
[09] wxEvtHandler::TryHereOnly(wxEvent&)         event.cpp:158
[10] wxEvtHandler::TryBeforeAndHere(wxEvent&)     event.h:367
[11] wxEvtHandler::ProcessEventLocally(wxEvent&)     event.cpp:152
[12] wxEvtHandler::ProcessEvent(wxEvent&)        event.cpp:149
[13] wxEvtHandler::ProcessPendingEvents()        event.cpp:135
[14] wxAppConsoleBase::ProcessPendingEvents()     appbase.cpp:52
[15] wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int)     evtloop_cf.cpp:9
[16] wxCFEventLoop::OSXCommonModeObserverCallBack(__CFRunLoopObserver*, int, void*)     evtloop_cf.cpp:7
[17] __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
[18] __CFRunLoopDoObservers                  
[19] __CFRunLoopRun                          
[20] CFRunLoopRunSpecific                    
       
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.


If I click of [Cancel], the program continues normally and works as expected, but the terminal window keeps sending this alert on every Paint.

I looked up the error online and checked the docs, and most times, this error happens when a wxPaintDC is declared outside a Paint callback, but in this program, the callback [04] on the call stack is the following:

void CCamView::OnPaint(wxPaintEvent &event)
{
    wxPaintDC dc
(this); //The alert happens here, before Draw(dc) is called
   
Draw(dc);
}

 
So I don't think that's the case.

Has anyone ever encountered a similar issue? The closest I found was <a href="http://stackoverflow.com/questions/28156821/issue-with-paint-event-on-mac-osx-10-8-5-in-wxpython" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F28156821%2Fissue-with-paint-event-on-mac-osx-10-8-5-in-wxpython\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_kQfiFTNKwVep0OiSVt_PE1q_PA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F28156821%2Fissue-with-paint-event-on-mac-osx-10-8-5-in-wxpython\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_kQfiFTNKwVep0OiSVt_PE1q_PA&#39;;return true;">this question on stack overflow, but it still looks very different from mine, and I don't completely understand the answer.

Thank you all for your attention, Arthur.

--
Please read <a href="http://www.wxwidgets.org/support/mlhowto.htm" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.wxwidgets.org%2Fsupport%2Fmlhowto.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGeLI38cNrlq2cC-jNsMzVrvhdIVA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.wxwidgets.org%2Fsupport%2Fmlhowto.htm\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGeLI38cNrlq2cC-jNsMzVrvhdIVA&#39;;return true;">http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="IIAihbHJCgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">wx-users+u...@googlegroups.com
or visit <a href="http://groups.google.com/group/wx-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://groups.google.com/group/wx-users&#39;;return true;" onclick="this.href=&#39;http://groups.google.com/group/wx-users&#39;;return true;">http://groups.google.com/group/wx-users

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [OSX] using wxPaintDC without being in a native paint event

Gerald Brandt

On 2017-04-03 12:16 AM, Arthur Moraes Do Lago wrote:
Hi,

1. I'm using wxWidgets 3.0.2
2. I'm on OSX 10.12.3(Sierra)
3. I compile using:
 ../configure --enable-debug --disable-mediactrl
and also, setting the follwing enviroment variables:
CXXFLAGS="-stdlib=libc++ -std=c++11" OBJCXXFLAGS="-stdlib=libc++ -std=c++11" LDFLAGS="-stdlib=libc++"

had to use --disable-mediactrl because some libraries, such as QuickTime.h were deprecated in OSX Sierra apparently, and the environment variables because some files like from some tr1 library were also missing, supposedly because the library was compiled using different version of stdlib.


Em domingo, 2 de abril de 2017 23:07:36 UTC-3, Igor Korot escreveu:
Hi,
Some basic questions:
1. Version of the library?
2. Version of the OS?
3. How did you build the library? 

Thank you. 



On Apr 2, 2017 9:26 PM, "Arthur Moraes Do Lago" <<a moz-do-not-send="true" href="javascript:" target="_blank" gdf-obfuscated-mailto="IIAihbHJCgAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">arthurmo...@...> wrote:
Hi,

I'm new to wxWidgets, and I'm having an issue running the program in <a moz-do-not-send="true" href="https://github.com/heinemml/wxOpenCV" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw';return true;">this repository, which is an updated version of this demo <a moz-do-not-send="true" href="http://larryo.org/work/information/wxopencv/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw';return true;">this demo for using wxWidgets with OpenCV.
It compiles normally, but when it starts to run, at the first Paint a window pops up with the following error:

../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef() != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a native paint event

Call stack:
[00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
[01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:14
[02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
[04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9
[05] wxAppConsoleBase::HandleEvent(wxEvtHandler*, void (wxEvtHandler::*)(wxEvent&), wxEvent&) const     appbase.cpp:61
[06] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const     appbase.cpp:62
[07] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)     event.cpp:139
[08] wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*)     event.cpp:99
[09] wxEvtHandler::TryHereOnly(wxEvent&)         event.cpp:158
[10] wxEvtHandler::TryBeforeAndHere(wxEvent&)     event.h:367
[11] wxEvtHandler::ProcessEventLocally(wxEvent&)     event.cpp:152
[12] wxEvtHandler::ProcessEvent(wxEvent&)        event.cpp:149
[13] wxEvtHandler::ProcessPendingEvents()        event.cpp:135
[14] wxAppConsoleBase::ProcessPendingEvents()     appbase.cpp:52
[15] wxCFEventLoop::CommonModeObserverCallBack(__CFRunLoopObserver*, int)     evtloop_cf.cpp:9
[16] wxCFEventLoop::OSXCommonModeObserverCallBack(__CFRunLoopObserver*, int, void*)     evtloop_cf.cpp:7
[17] __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
[18] __CFRunLoopDoObservers                  
[19] __CFRunLoopRun                          
[20] CFRunLoopRunSpecific                    
       
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.


If I click of [Cancel], the program continues normally and works as expected, but the terminal window keeps sending this alert on every Paint.

I looked up the error online and checked the docs, and most times, this error happens when a wxPaintDC is declared outside a Paint callback, but in this program, the callback [04] on the call stack is the following:

void CCamView::OnPaint(wxPaintEvent &event)
{
    wxPaintDC dc
(this); //The alert happens here, before Draw(dc) is called
   
Draw(dc);
}

 
So I don't think that's the case.

Has anyone ever encountered a similar issue? The closest I found was <a moz-do-not-send="true" href="http://stackoverflow.com/questions/28156821/issue-with-paint-event-on-mac-osx-10-8-5-in-wxpython" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F28156821%2Fissue-with-paint-event-on-mac-osx-10-8-5-in-wxpython\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_kQfiFTNKwVep0OiSVt_PE1q_PA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fstackoverflow.com%2Fquestions%2F28156821%2Fissue-with-paint-event-on-mac-osx-10-8-5-in-wxpython\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG_kQfiFTNKwVep0OiSVt_PE1q_PA';return true;">this question on stack overflow, but it still looks very different from mine, and I don't completely understand the answer.

Thank you all for your attention, Arthur.


When you're not in a paint event, use wxClientDC instead.


http://docs.wxwidgets.org/trunk/classwx_client_d_c.html


Gerald

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [OSX] using wxPaintDC without being in a native paint event

Vadim Zeitlin-4
In reply to this post by Arthur Moraes Do Lago
On Sun, 2 Apr 2017 18:21:35 -0700 (PDT) Arthur Moraes Do Lago wrote:

AMDL> I'm new to wxWidgets, and I'm having an issue running the program in this
AMDL> repository <https://github.com/heinemml/wxOpenCV>, which is an updated
AMDL> version of this demo this demo
AMDL> <http://larryo.org/work/information/wxopencv/> for using wxWidgets with
AMDL> OpenCV.
AMDL> It compiles normally, but when it starts to run, at the first Paint a
AMDL> window pops up with the following error:
AMDL>
AMDL> ../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef()
AMDL> != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a
AMDL> native paint event
AMDL>
AMDL> Call stack:
AMDL> [00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
AMDL> [01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:
AMDL> 14
AMDL> [02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
AMDL> [03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
AMDL> [04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9

 Something seems wrong with the line numbers, is the last digit truncated
or something? At least if you're using the sources from
https://github.com/heinemml/wxOpenCV/blob/master/src/gui/camview.cpp it
looks like the last one should be line "94", not "9".

AMDL> I looked up the error online and checked the docs, and most times,
AMDL> this error happens when a wxPaintDC is declared outside a Paint
AMDL> callback,

 Indeed.

AMDL> but in this program, the callback [04] on the call stack is
AMDL> the following:
AMDL>
AMDL> void CCamView::OnPaint(wxPaintEvent &event)
AMDL> {
AMDL>     wxPaintDC dc(this); //The alert happens here, before Draw(dc) is called
AMDL>     Draw(dc);
AMDL> }
AMDL>
AMDL> So I don't think that's the case.

 Yes, I don't see anything wrong here. However the code in DrawCam(), in
the same file, which posts a wxPaintEvent is definitely wrong, you (well,
the original author of the code) should never do this, the proper way to
trigger a repaint of the window is to call Refresh(), not post paint event
to it. Does fixing this help by chance?

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [OSX] using wxPaintDC without being in a native paint event

Arthur Moraes Do Lago
Oh, commenting those two lines forcing an event and using Refresh solved it!
I did run a directory-wide search for any inappropriate call to CCamView::OnPaint, but I didn't know you could force an event like that, so I didn't notice that function.
About the line numbers, I don't think they are truncated, or at least, that's exactly what the alert showed me, but it's strange indeed. But it is now gone, so no need to worry about that.

Thank you very much for your help!




Em segunda-feira, 3 de abril de 2017 09:41:01 UTC-3, Vadim Zeitlin escreveu:
On Sun, 2 Apr 2017 18:21:35 -0700 (PDT) Arthur Moraes Do Lago wrote:

AMDL> I'm new to wxWidgets, and I'm having an issue running the program in this
AMDL> repository <<a href="https://github.com/heinemml/wxOpenCV" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXPQ1WHBR7sfJGU1YWARd4o9GMhw&#39;;return true;">https://github.com/heinemml/wxOpenCV>, which is an updated
AMDL> version of this demo this demo
AMDL> <<a href="http://larryo.org/work/information/wxopencv/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Flarryo.org%2Fwork%2Finformation%2Fwxopencv%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFvtIGvmAuEdWNaHL4Y0v950mAhrw&#39;;return true;">http://larryo.org/work/information/wxopencv/> for using wxWidgets with
AMDL> OpenCV.
AMDL> It compiles normally, but when it starts to run, at the first Paint a
AMDL> window pops up with the following error:
AMDL>
AMDL> ../src/osx/carbon/dcclient.cpp(195): assert "window->MacGetCGContextRef()
AMDL> != NULL" failed in wxPaintDCImpl(): using wxPaintDC without being in a
AMDL> native paint event
AMDL>
AMDL> Call stack:
AMDL> [00] wxPaintDCImpl::wxPaintDCImpl(wxDC*, wxWindow*)     dcclient.cpp:20
AMDL> [01] wxNativeDCFactory::CreatePaintDC(wxPaintDC*, wxWindow*)     dcbase.cpp:
AMDL> 14
AMDL> [02] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
AMDL> [03] wxPaintDC::wxPaintDC(wxWindow*)             dcbase.cpp:27
AMDL> [04] CCamView::OnPaint(wxPaintEvent&)            camview.cpp:9

 Something seems wrong with the line numbers, is the last digit truncated
or something? At least if you're using the sources from
<a href="https://github.com/heinemml/wxOpenCV/blob/master/src/gui/camview.cpp" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV%2Fblob%2Fmaster%2Fsrc%2Fgui%2Fcamview.cpp\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFpQyKSvCDp5fcK7ldJG3MmVhAjxA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fheinemml%2FwxOpenCV%2Fblob%2Fmaster%2Fsrc%2Fgui%2Fcamview.cpp\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFpQyKSvCDp5fcK7ldJG3MmVhAjxA&#39;;return true;">https://github.com/heinemml/wxOpenCV/blob/master/src/gui/camview.cpp it
looks like the last one should be line "94", not "9".

AMDL> I looked up the error online and checked the docs, and most times,
AMDL> this error happens when a wxPaintDC is declared outside a Paint
AMDL> callback,

 Indeed.

AMDL> but in this program, the callback [04] on the call stack is
AMDL> the following:
AMDL>
AMDL> void CCamView::OnPaint(wxPaintEvent &event)
AMDL> {
AMDL>     wxPaintDC dc(this); //The alert happens here, before Draw(dc) is called
AMDL>     Draw(dc);
AMDL> }
AMDL>
AMDL> So I don't think that's the case.

 Yes, I don't see anything wrong here. However the code in DrawCam(), in
the same file, which posts a wxPaintEvent is definitely wrong, you (well,
the original author of the code) should never do this, the proper way to
trigger a repaint of the window is to call Refresh(), not post paint event
to it. Does fixing this help by chance?

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               <a href="http://www.tt-solutions.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.tt-solutions.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFhPHTZbdYZYM-AqcnZXykG1ueWhw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.tt-solutions.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFhPHTZbdYZYM-AqcnZXykG1ueWhw&#39;;return true;">http://www.tt-solutions.com/

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Loading...