diff options
author | Sverker Eriksson <[email protected]> | 2017-08-30 20:55:08 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-08-30 20:55:08 +0200 |
commit | 7c67bbddb53c364086f66260701bc54a61c9659c (patch) | |
tree | 92ab0d4b91d5e2f6e7a3f9d61ea25089e8a71fe0 /lib/wx/src/wxe_master.erl | |
parent | 97dc5e7f396129222419811c173edc7fa767b0f8 (diff) | |
parent | 3b7a6ffddc819bf305353a593904cea9e932e7dc (diff) | |
download | otp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.gz otp-7c67bbddb53c364086f66260701bc54a61c9659c.tar.bz2 otp-7c67bbddb53c364086f66260701bc54a61c9659c.zip |
Merge tag 'OTP-19.0' into sverker/19/binary_to_atom-utf8-crash/ERL-474/OTP-14590
Diffstat (limited to 'lib/wx/src/wxe_master.erl')
-rw-r--r-- | lib/wx/src/wxe_master.erl | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/lib/wx/src/wxe_master.erl b/lib/wx/src/wxe_master.erl index b98a7c793e..e17a3327ac 100644 --- a/lib/wx/src/wxe_master.erl +++ b/lib/wx/src/wxe_master.erl @@ -1,18 +1,19 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2012. All Rights Reserved. +%% Copyright Ericsson AB 2008-2016. All Rights Reserved. %% -%% The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at %% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. %% %% %CopyrightEnd% %%%------------------------------------------------------------------- @@ -28,7 +29,7 @@ -behaviour(gen_server). %% API --export([start/1, init_port/1, init_opengl/0]). +-export([start/1, init_port/1, init_opengl/0, fetch_msgs/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -36,7 +37,9 @@ -record(state, {cb_port, %% Callback port and to erlang messages goes via it. users, %% List of wx servers, needed ?? - driver}). %% Driver name so wx_server can create it's own port + driver, %% Driver name so wx_server can create it's own port + msgs=[] %% Early messages (such as openfiles on OSX) + }). -include("wxe.hrl"). -include("gen/wxe_debug.hrl"). @@ -76,12 +79,18 @@ init_port(SilentStart) -> %%-------------------------------------------------------------------- -%% Initlizes the opengl library +%% Initalizes the opengl library %%-------------------------------------------------------------------- init_opengl() -> GLLib = wxe_util:wxgl_dl(), wxe_util:call(?WXE_INIT_OPENGL, <<(list_to_binary(GLLib))/binary, 0:8>>). +%%-------------------------------------------------------------------- +%% Fetch early messages, hack to get start up args on mac +%%-------------------------------------------------------------------- +fetch_msgs() -> + gen_server:call(?MODULE, fetch_msgs, infinity). + %%==================================================================== %% gen_server callbacks %%==================================================================== @@ -152,6 +161,8 @@ init([SilentStart]) -> %%-------------------------------------------------------------------- handle_call(init_port, From, State=#state{driver=Driver,cb_port=CBPort, users=Users}) -> {reply, {Driver,CBPort}, State#state{users=gb_sets:add(From,Users)}}; +handle_call(fetch_msgs, _From, State=#state{msgs=Msgs}) -> + {reply, lists:reverse(Msgs), State#state{msgs=[]}}; handle_call(_Request, _From, State) -> %%io:format("Unknown request ~p sent to ~p from ~p ~n",[_Request, ?MODULE, _From]), Reply = ok, @@ -174,14 +185,16 @@ handle_cast(_Msg, State) -> %% Description: Handling all non call/cast messages %%-------------------------------------------------------------------- handle_info({wxe_driver, error, Msg}, State) -> - error_logger:format("WX ERROR: ~s~n", [Msg]), + error_logger:error_report([{wx, error}, {message, lists:flatten(Msg)}]), {noreply, State}; handle_info({wxe_driver, internal_error, Msg}, State) -> - error_logger:format("WX INTERNAL ERROR: ~s~n", [Msg]), + error_logger:error_report([{wx, internal_error}, {message, lists:flatten(Msg)}]), {noreply, State}; handle_info({wxe_driver, debug, Msg}, State) -> io:format("WX DBG: ~s~n", [Msg]), {noreply, State}; +handle_info({wxe_driver, open_file, File}, State=#state{msgs=Msgs}) -> + {noreply, State#state{msgs=[File|Msgs]}}; handle_info(_Info, State) -> io:format("Unknown message ~p sent to ~p~n",[_Info, ?MODULE]), {noreply, State}. |