2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <pbd/base_ui.h>
26 #include <pbd/error.h>
27 #include <pbd/compose.h>
28 #include <pbd/failed_constructor.h>
35 uint32_t BaseUI::rt_bit = 1;
36 BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
38 BaseUI::BaseUI (string str, bool with_signal_pipe)
41 /* odd pseudo-singleton semantics */
43 base_ui_instance = this;
48 if (with_signal_pipe) {
49 if (setup_signal_pipe ()) {
50 throw failed_constructor ();
57 if (signal_pipe[0] >= 0) {
58 close (signal_pipe[0]);
61 if (signal_pipe[1] >= 0) {
62 close (signal_pipe[1]);
67 BaseUI::new_request_type ()
71 /* XXX catch out-of-range */
73 rt = RequestType (rt_bit);
80 BaseUI::setup_signal_pipe ()
82 /* setup the pipe that other threads send us notifications/requests
86 if (pipe (signal_pipe)) {
87 error << string_compose (_("%1-UI: cannot create error signal pipe (%2)"), _name, std::strerror (errno))
93 if (fcntl (signal_pipe[0], F_SETFL, O_NONBLOCK)) {
94 error << string_compose (_("%1-UI: cannot set O_NONBLOCK on signal read pipe (%2)"), _name, std::strerror (errno))
99 if (fcntl (signal_pipe[1], F_SETFL, O_NONBLOCK)) {
100 error << string_compose (_("%1-UI: cannot set O_NONBLOCK on signal write pipe (%2)"), _name, std::strerror (errno))