Hi Vadim,

thank you for the patches - I reviewed and applied them. It's also good 
timing since I already wanted to ask the wxWidgets list if I need to 
delete the wxGraphicsContext object on my own. I do have a question 
though about a problem with the wxGraphicsContext backend of the 
wxWidgets driver which puzzles me now for some weeks and I can't find a 
solution to that problem. It's also hard to debug and maybe you can 
point me in the right direction. Since you already have the plplot 
source compiled, maybe it's not too time consuming for you to have a 
short look at it.

I use Visual C++ 2008, wxMWS 2.8.9 (shared, debug or release,  
USE_GDIPLUS=1 and #define wxUSE_GRAPHICS_CONTEXT 1 in setup.h) and the 
latest PLplot version from svn. I use the following line to configure 
PLplot:

cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug 
-DwxWidgets_CONFIGURATION=mswd -DBUILD_TEST=ON path_to_source

The BUILD_TEST=ON option will also build all examples in the build tree. 
Also dynamic drivers are used, so all drivers are in its own dll. After 
nmake, I run examples\c++\wxPLplotdemo.exe and I can see that the 
wxGraphicsContext backend is used and works. I can close the application 
without problem. But if I run one of the console examples, e.g. 
examples\c\x01.exe and choose the wxWidgets driver again I can see that 
the wxGraphicsContext backend is used, but when I close the program it 
hangs. I can't even stop it with Ctrl-C.

If I attach Visual C++ 2008 to the not responding executable and do a 
"Break All" I get:

"The process appears to be deadlocked (or is not running any user-mode 
code). All threads have been stopped."

The program has stopped at line 51 of ltdl_win32.c where the dll is freed:

      FreeLibrary( lastHandle->hinstLib );

The call stack looks like that:

GdiPlus.dll!4ebbfedd()    
GdiPlus.dll!4ebbfeb4()    
msvcr90d.dll!102560e2()    
plplotd.dll!lt_dlexit()  Line 51 + 0x11 bytes    C

If I use the standard (wxDC) backend with "examples\c\x01c.exe -dev 
wxwidgets -drvopt backend=0" the program closes correctly, so this is a 
wxGraphicsContext issue.

If I disable dynamic drivers (cmake option -DENABLE_DYNDRIVERS=OFF) this 
problem also doesn't occur (FreeLibary is never called since the import 
library of the plplot dll is linked in). I try to debug this now for 
weeks but in the moment I'm completely at loss where to proceed.

Could you perhaps verify that this problem occurs for you as well and do 
you have any propositions how to debug this?

Thanks,
Werner

Vadim Zeitlin wrote:
>  Hello again,
>
>  Here is another tiny patch, this one to fix a memory leak:
>
> diff -r 7578c8ba1630 drivers/wxwidgets_gc.cpp
> --- a/drivers/wxwidgets_gc.cpp  Wed Mar 11 14:37:03 2009 +0100
> +++ b/drivers/wxwidgets_gc.cpp  Wed Mar 11 14:40:59 2009 +0100
> @@ -68,6 +68,8 @@
>
>    if( m_font )
>      delete m_font;
> +
> +  delete m_context;
>  }
>
>
>  This needs to be done because m_context is returned from
> wxGraphicsContext::Create() and its return value must be deleted by caller,
> without it each call to wxPLDevGC::SetExternalBuffer() leaks memory.
>
>  Notice that I didn't add a "if( m_context )" check before the delete as it
> is unnecessary (the result of calling delete NULL is defined as a NOP) but,
> of course, please feel free to add it for consistency with the lines above
> if you prefer (or, better, remove the checks above too :-).
>
>  Thanks again,
> VZ
>   
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> ------------------------------------------------------------------------
>
> _______________________________________________
> Plplot-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>   


-- 
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria
DVR-Nr: 0005886

email: [email protected]
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
       +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to