diff options
author | HÃ¥kan Mattsson <[email protected]> | 2012-06-12 13:25:01 +0200 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2012-11-19 10:39:46 +0100 |
commit | 61ec7e2dc50b15e2677771c72a372bf0daf00950 (patch) | |
tree | 2a2581f8adf374ec2061943ebbd5a56d0cd86d6a /lib/wx/src/wxe_master.erl | |
parent | 5f3a7727464522da88d07a3012aa87b8703e3f3a (diff) | |
download | otp-61ec7e2dc50b15e2677771c72a372bf0daf00950.tar.gz otp-61ec7e2dc50b15e2677771c72a372bf0daf00950.tar.bz2 otp-61ec7e2dc50b15e2677771c72a372bf0daf00950.zip |
Enable silent start of wx
Add {silent_start, boolean()} option to wx:new/1 in order to be able
to suppress error messages during startup of wx.
Diffstat (limited to 'lib/wx/src/wxe_master.erl')
-rw-r--r-- | lib/wx/src/wxe_master.erl | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/wx/src/wxe_master.erl b/lib/wx/src/wxe_master.erl index ac6e4a56e6..b98a7c793e 100644 --- a/lib/wx/src/wxe_master.erl +++ b/lib/wx/src/wxe_master.erl @@ -28,7 +28,7 @@ -behaviour(gen_server). %% API --export([start/0, init_port/0, init_opengl/0]). +-export([start/1, init_port/1, init_opengl/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -47,20 +47,20 @@ %% API %%==================================================================== %%-------------------------------------------------------------------- -%% Function: start_link() -> {ok,Pid} | ignore | {error,Error} +%% Function: start(SilentStart) -> {ok,Pid} | ignore | {error,Error} %% Description: Starts the server %%-------------------------------------------------------------------- -start() -> - gen_server:start({local, ?MODULE}, ?MODULE, [], []). +start(SilentStart) -> + gen_server:start({local, ?MODULE}, ?MODULE, [SilentStart], []). %%-------------------------------------------------------------------- -%% Function: init_port() -> {UserPort,CallBackPort} | error(Error) +%% Function: init_port(SilentStart) -> {UserPort,CallBackPort} | error(Error) %% Description: Creates the port %%-------------------------------------------------------------------- -init_port() -> +init_port(SilentStart) -> case whereis(?MODULE) of undefined -> - case start() of + case start(SilentStart) of {ok,Pid} -> Pid; {error,{already_started,Pid}} -> Pid; {error, {Reason,Stack}} -> @@ -93,14 +93,17 @@ init_opengl() -> %% {stop, Reason} %% Description: Initiates the server %%-------------------------------------------------------------------- -init([]) -> +init([SilentStart]) -> DriverName = ?DRIVER, - PrivDir = wxe_util:priv_dir(?DRIVER), + PrivDir = wxe_util:priv_dir(?DRIVER, SilentStart), erlang:group_leader(whereis(init), self()), case catch erlang:system_info(smp_support) of true -> ok; _ -> - error_logger:format("WX ERROR: SMP emulator required (start with erl -smp)", []), + wxe_util:opt_error_log(SilentStart, + "WX ERROR: SMP emulator required" + " (start with erl -smp)", + []), erlang:error(not_smp) end, @@ -114,7 +117,9 @@ init([]) -> case erl_ddll:load_driver(PrivDir,DriverName) of ok -> ok; {error, What} -> - error_logger:format("WX Failed loading ~p@~p ~n", [DriverName,PrivDir]), + wxe_util:opt_error_log(SilentStart, + "WX Failed loading ~p@~p ~n", + [DriverName,PrivDir]), Str = erl_ddll:format_error(What), erlang:error({load_driver,Str}) end, @@ -210,4 +215,3 @@ debug_ping(Port) -> _R = (catch erlang:port_call(Port, 0, [])), %% io:format("Erlang ping ~p ~n", [_R]), debug_ping(Port). - |