diff options
author | Dan Gudmundsson <[email protected]> | 2012-11-21 14:46:57 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2013-01-09 11:44:29 +0100 |
commit | e0bd4e45ab947aef0600025d16d7df6502238e92 (patch) | |
tree | fccc7958856deac73c4d0f86521786e264a46970 /lib/observer/src | |
parent | c2cfdee17a539de46345c4f9c2faf1dc03ccb596 (diff) | |
download | otp-e0bd4e45ab947aef0600025d16d7df6502238e92.tar.gz otp-e0bd4e45ab947aef0600025d16d7df6502238e92.tar.bz2 otp-e0bd4e45ab947aef0600025d16d7df6502238e92.zip |
observer: Fix check for graphics contexts
wxWidgets-2.9 seg faults if you try to create a graphics context
before the window is shown.
With bad timing this can happen.
So change the haveGC test to check if the functionality is available
without creating the GraphicsContext.
Diffstat (limited to 'lib/observer/src')
-rw-r--r-- | lib/observer/src/observer_app_wx.erl | 4 | ||||
-rw-r--r-- | lib/observer/src/observer_perf_wx.erl | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl index b574307007..72bafcc5e0 100644 --- a/lib/observer/src/observer_app_wx.erl +++ b/lib/observer/src/observer_app_wx.erl @@ -28,7 +28,7 @@ -include("observer_defs.hrl"). %% Import drawing wrappers --import(observer_perf_wx, [haveGC/1, +-import(observer_perf_wx, [haveGC/0, setPen/2, setFont/3, setBrush/2, strokeLine/5, strokeLines/2, drawRoundedRectangle/6, drawText/4, getTextExtent/2]). @@ -114,7 +114,7 @@ init([Notebook, Parent]) -> _ -> ok end, - UseGC = haveGC(DrawingArea), + UseGC = haveGC(), Version28 = ?wxMAJOR_VERSION =:= 2 andalso ?wxMINOR_VERSION =:= 8, Font = case os:type() of {unix,_} when UseGC, Version28 -> diff --git a/lib/observer/src/observer_perf_wx.erl b/lib/observer/src/observer_perf_wx.erl index d0dd46b402..54c98f3ba3 100644 --- a/lib/observer/src/observer_perf_wx.erl +++ b/lib/observer/src/observer_perf_wx.erl @@ -24,7 +24,7 @@ handle_event/2, handle_sync_event/3, handle_cast/2]). %% Drawing wrappers for DC and GC areas --export([haveGC/1, +-export([haveGC/0, setPen/2, setFont/3, setBrush/2, strokeLine/5, strokeLines/2, drawRoundedRectangle/6, drawText/4, getTextExtent/2]). @@ -90,7 +90,7 @@ init([Notebook, Parent]) -> _ -> ok end, - UseGC = haveGC(Panel), + UseGC = haveGC(), Version28 = ?wxMAJOR_VERSION =:= 2 andalso ?wxMINOR_VERSION =:= 8, {Font, SmallFont} = case os:type() of @@ -525,10 +525,9 @@ colors() -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% wxDC and ?wxGC wrappers -haveGC(Win) -> +haveGC() -> try - GC = ?wxGC:create(Win), - ?wxGC:destroy(GC), + wxGraphicsRenderer:getDefaultRenderer(), true catch _:_ -> false end. |