Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crash 0xC0000005 with wxVisualAttributes #1198

Closed
kdschlosser opened this issue Apr 12, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@kdschlosser
Copy link

commented Apr 12, 2019

System: Windows 6.1.7601 x64
Python: 2.7.15 (Stackless Python)
Python Compiler: MSC v.1500 32 bit (Intel)
wxPython Version: 4.0.4 msw (phoenix) wxWidgets 3.0.5 (pip installation)

Operating system:
Python version & source:

Description of the problem:

I know this is a trivial issue. But it is worth mentioning because the underlying issue could be more widespread.

When I get the ClassDefaultAttributes of a class if the returned wxVisualAttributes if not placed into a python variable when trying to print out say the bgCol property an application crash takes place.

here is the exit code exit code -1073741819 (0xC0000005)

The script will cause the issue when running on python 2.7.15 and using wxPython 4.0.4. I have not tried this with any other versions of python. if you would like me to I can.

I am using Stackless Python and I do know that there is an issue with Stackless python and Cython. I do not know if the issue spreads over to swig as well. The problem with Stackless and Cython has been resolved and is in a new release of Stackless which I will also test to see if the problem occurs.

Again this is something that is really strange because everything works fine so long as I create a reference to the returned object before printing it.

NOTE: This script was run inside of the PyCharm IDE, and the IDE does manipulate sys.stdout. I will try this again without the IDE and report back.

sample code to try.

from __future__ import print_function
import wx
import platform

print('System:', platform.system(), platform.version())
print('Python:', platform.python_version())
print('Python Compiler:', platform.python_compiler())
print('wxPython version:', wx.version())
print()

print('You will see a python appcrash 0xC0000005 when running this script')

visual_attributes = wx.Window.GetClassDefaultAttributes()
print('wxVisualAttributes set into a python variable (visual_attributes) using wx.Window.GetClassDefaultAttributes()')
print('visual_attributes:', visual_attributes)
print('visual_attributes.colBg:', visual_attributes.colBg)

print('not creating variable and printing directly from the call to wx.Window.GetClassDefaultAttributes()')
print('wx.Window.GetClassDefaultAttributes():', wx.Window.GetClassDefaultAttributes())
print('wx.Window.GetClassDefaultAttributes().colBg:', wx.Window.GetClassDefaultAttributes().colBg)

output from script

System: Windows 6.1.7601
Python: 2.7.15
Python Compiler: MSC v.1500 32 bit (Intel)
wxPython version: 4.0.4 msw (phoenix) wxWidgets 3.0.5
You will see a python appcrash 0xC0000005 when running this script
wxVisualAttributes set into a python variable (visual_attributes) using wx.Window.GetClassDefaultAttributes()
visual_attributes: <wx._core.VisualAttributes object at 0x031BA080>
visual_attributes.colBg: (240, 240, 240, 255)
not creating variable and printing directly from the call to wx.Window.GetClassDefaultAttributes()
wx.Window.GetClassDefaultAttributes(): <wx._core.VisualAttributes object at 0x031BA0D0>
wx.Window.GetClassDefaultAttributes().colBg: 
Process finished with exit code -1073741819 (0xC0000005)
@RobinD42

This comment has been minimized.

Copy link
Member

commented Apr 13, 2019

Fixed by #1201

@RobinD42 RobinD42 closed this Apr 13, 2019

@kdschlosser

This comment has been minimized.

Copy link
Author

commented Apr 14, 2019

I would also like to know if there is a way to define the default class attributes?. In the world of GUI controls it seems to be a pretty popular thing to be able to "skin" the GUI. I have not seen anything that jumps right out as far as setting global colors/fonts/sizes. There is the ArtManager that is available for artwork and that works well. As far as fonts, colors and GUI element sizes like scroll bar widths and things of that nature I have not managed to locate a simple way to make the changes globally and I have not be able to locate a way to force all visible GUI items to be refreshed or redrawn. From what I have found is that I have to iterate over all of the children of the base application frame and set them specifically. Maybe I am missing something about how to go about doing this. That is the reason why i discovered the issue with the wx.VisualAttributes. Also are there any other properties that can get set to the wx.VisualAttributes instance that are not documented?. The documentation suggests that there is but does not specifically reference any additional properties.

I know this would be more of a support question. I thought since this does have to do with the wx.VisualAttributes object I might get away with asking here.

@RobinD42

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

No, since wxWidgets is all about using the native widgets and having a true native LnF on all platforms as much as possible, then there really isn't support for things like skinning or custom theming. The themes, if any, are handled by the platform. So the wx.VisualAttributes are more-or-less read-only, there is no SetVisualAttributes or similar.

That said, there is a bit of attribute inheritance that has been there for a long time. For example if a font or color is set on a panel before creating child widgets, then those widgets may inherit and use that font or color. Unfortunately it's not entirely consistent, and is getting worse as the native platforms impose more control over the LnF. A decade or so ago it worked for most widgets on Windows or GTK, but now not so much.

@kdschlosser

This comment has been minimized.

Copy link
Author

commented Apr 18, 2019

OK so the easiest solution would be to subclass all of the wxWindow based classes override the init to Bind to EVT_WINDOW_DESTROY and place that instance into a container that holds active controls and if it gets destroyed it would be able to be removed from that container. and then override the existing classes with the subclassed ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.