summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-27 17:57:35 +0100
committerDavid Robillard <d@drobilla.net>2020-11-27 21:42:51 +0100
commit8edaca929cbc619d47e799f19494d1b3b6c4dd2f (patch)
tree8cb043ac82d7519ca4b6de2791cbb02d4e2b218a
parent976d937b2fdf24c76b6b5575afc6cbe222a87b63 (diff)
downloadpatchage-8edaca929cbc619d47e799f19494d1b3b6c4dd2f.tar.gz
patchage-8edaca929cbc619d47e799f19494d1b3b6c4dd2f.tar.bz2
patchage-8edaca929cbc619d47e799f19494d1b3b6c4dd2f.zip
Use nullptr
-rw-r--r--.clang-tidy1
-rw-r--r--src/AlsaDriver.cpp26
-rw-r--r--src/AlsaDriver.hpp2
-rw-r--r--src/JackDbusDriver.cpp20
-rw-r--r--src/JackDriver.cpp39
-rw-r--r--src/JackDriver.hpp2
-rw-r--r--src/Patchage.cpp22
-rw-r--r--src/PatchageCanvas.cpp20
-rw-r--r--src/PatchageEvent.cpp8
-rw-r--r--src/PatchageEvent.hpp6
-rw-r--r--src/PatchageModule.cpp8
-rw-r--r--wscript1
12 files changed, 78 insertions, 77 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 8e7c23d..6d00d38 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -49,7 +49,6 @@ Checks: >
-llvmlibc-*,
-misc-unused-parameters,
-modernize-loop-convert,
- -modernize-use-nullptr,
-modernize-use-trailing-return-type,
-modernize-use-using,
-performance-faster-string-find,
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 4ad2897..f34fb1b 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -32,7 +32,7 @@ using boost::format;
AlsaDriver::AlsaDriver(Patchage* app)
: _app(app)
- , _seq(NULL)
+ , _seq(nullptr)
{}
AlsaDriver::~AlsaDriver()
@@ -47,7 +47,7 @@ AlsaDriver::attach(bool /*launch_daemon*/)
int ret = snd_seq_open(&_seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
if (ret) {
_app->error_msg("Alsa: Unable to attach.");
- _seq = NULL;
+ _seq = nullptr;
} else {
_app->info_msg("Alsa: Attached.");
@@ -71,9 +71,9 @@ AlsaDriver::detach()
{
if (_seq) {
pthread_cancel(_refresh_thread);
- pthread_join(_refresh_thread, NULL);
+ pthread_join(_refresh_thread, nullptr);
snd_seq_close(_seq);
- _seq = NULL;
+ _seq = nullptr;
signal_detached.emit();
_app->info_msg("Alsa: Detached.");
}
@@ -116,8 +116,8 @@ AlsaDriver::refresh()
snd_seq_port_info_t* pinfo;
snd_seq_port_info_alloca(&pinfo);
- PatchageModule* parent = NULL;
- PatchagePort* port = NULL;
+ PatchageModule* parent = nullptr;
+ PatchagePort* port = nullptr;
// Create port views
while (snd_seq_query_next_client(_seq, cinfo) >= 0) {
@@ -177,8 +177,8 @@ AlsaDriver::refresh()
PatchagePort*
AlsaDriver::create_port_view(Patchage* patchage, const PortID& id)
{
- PatchageModule* parent = NULL;
- PatchagePort* port = NULL;
+ PatchageModule* parent = nullptr;
+ PatchagePort* port = nullptr;
create_port_view_internal(patchage, id.id.alsa_addr, parent, port);
return port;
}
@@ -188,9 +188,9 @@ AlsaDriver::find_module(uint8_t client_id, ModuleType type)
{
const Modules::const_iterator i = _modules.find(client_id);
if (i == _modules.end())
- return NULL;
+ return nullptr;
- PatchageModule* io_module = NULL;
+ PatchageModule* io_module = nullptr;
for (Modules::const_iterator j = i;
j != _modules.end() && j->first == client_id;
++j) {
@@ -201,7 +201,7 @@ AlsaDriver::find_module(uint8_t client_id, ModuleType type)
}
}
- // Return InputOutput module for Input or Output, or NULL if not found
+ // Return InputOutput module for Input or Output, or null if not found
return io_module;
}
@@ -508,7 +508,7 @@ AlsaDriver::refresh_main(void* me)
{
AlsaDriver* ad = (AlsaDriver*)me;
ad->_refresh_main();
- return NULL;
+ return nullptr;
}
void
diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp
index 7428db2..a1de0e7 100644
--- a/src/AlsaDriver.hpp
+++ b/src/AlsaDriver.hpp
@@ -42,7 +42,7 @@ public:
void attach(bool launch_daemon = false);
void detach();
- bool is_attached() const { return (_seq != NULL); }
+ bool is_attached() const { return (_seq != nullptr); }
void refresh();
void destroy_all();
diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp
index 0646b4d..9c478ef 100644
--- a/src/JackDbusDriver.cpp
+++ b/src/JackDbusDriver.cpp
@@ -1,4 +1,5 @@
/* This file is part of Patchage.
+ * Copyright 2008-2020 David Robillard <d@drobilla.net>
* Copyright 2008 Nedko Arnaudov <nedko@arnaudov.name>
*
* Patchage is free software: you can redistribute it and/or modify it under
@@ -522,36 +523,37 @@ JackDriver::attach(bool launch_daemon)
return;
}
- dbus_connection_setup_with_g_main(_dbus_connection, NULL);
+ dbus_connection_setup_with_g_main(_dbus_connection, nullptr);
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" DBUS_INTERFACE_DBUS
"',member=NameOwnerChanged,arg0='org.jackaudio.service'",
- NULL);
+ nullptr);
#if defined(USE_FULL_REFRESH)
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
"',member=GraphChanged",
- NULL);
+ nullptr);
#else
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
"',member=PortAppeared",
- NULL);
+ nullptr);
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
"',member=PortDisappeared",
- NULL);
+ nullptr);
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
"',member=PortsConnected",
- NULL);
+ nullptr);
dbus_bus_add_match(_dbus_connection,
"type='signal',interface='" JACKDBUS_IFACE_PATCHBAY
"',member=PortsDisconnected",
- NULL);
+ nullptr);
#endif
- dbus_connection_add_filter(_dbus_connection, dbus_message_hook, this, NULL);
+ dbus_connection_add_filter(
+ _dbus_connection, dbus_message_hook, this, nullptr);
update_attached();
@@ -1180,7 +1182,7 @@ PatchagePort*
JackDriver::create_port_view(Patchage* patchage, const PortID& id)
{
assert(false); // we dont use events at all
- return NULL;
+ return nullptr;
}
void
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 097b1aa..c4a1b6f 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -41,7 +41,7 @@ using boost::format;
JackDriver::JackDriver(Patchage* app)
: _app(app)
- , _client(NULL)
+ , _client(nullptr)
, _events(128)
, _xruns(0)
, _xrun_delay(0)
@@ -67,8 +67,8 @@ JackDriver::attach(bool launch_daemon)
jack_options_t options =
(!launch_daemon) ? JackNoStartServer : JackNullOption;
- _client = jack_client_open("Patchage", options, NULL);
- if (_client == NULL) {
+ _client = jack_client_open("Patchage", options, nullptr);
+ if (_client == nullptr) {
_app->error_msg("Jack: Unable to create client.");
_is_activated = false;
} else {
@@ -103,7 +103,7 @@ JackDriver::detach()
if (_client) {
jack_deactivate(_client);
jack_client_close(_client);
- _client = NULL;
+ _client = nullptr;
}
_is_activated = false;
signal_detached.emit();
@@ -137,7 +137,7 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id)
_app->error_msg(
(format("Jack: Failed to find port with ID `%1%'.") % id).str());
;
- return NULL;
+ return nullptr;
}
const int jack_flags = jack_port_flags(jack_port);
@@ -166,7 +166,7 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id)
_app->error_msg((format("Jack: Module `%1%' already has port `%2%'.") %
module_name % port_name)
.str());
- return NULL;
+ return nullptr;
}
PatchagePort* port = create_port(*parent, jack_port, id);
@@ -184,8 +184,8 @@ get_property(jack_uuid_t subject, const char* key)
{
std::string result;
- char* value = NULL;
- char* datatype = NULL;
+ char* value = nullptr;
+ char* datatype = nullptr;
if (!jack_get_property(subject, key, &value, &datatype)) {
result = value;
}
@@ -200,7 +200,7 @@ PatchagePort*
JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
{
if (!port) {
- return NULL;
+ return nullptr;
}
std::string label;
@@ -237,7 +237,7 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
_app->warning_msg((format("Jack: Port `%1%' has unknown type `%2%'.") %
jack_port_name(port) % type_str)
.str());
- return NULL;
+ return nullptr;
}
PatchagePort* ret(
@@ -277,12 +277,13 @@ JackDriver::refresh()
Glib::Mutex::Lock lock(_shutdown_mutex);
- if (_client == NULL) {
+ if (_client == nullptr) {
shutdown();
return;
}
- ports = jack_get_ports(_client, NULL, NULL, 0); // get all existing ports
+ ports =
+ jack_get_ports(_client, nullptr, nullptr, 0); // get all existing ports
if (!ports) {
return;
@@ -360,8 +361,8 @@ JackDriver::refresh()
if (!port1 || !port2)
continue;
- Ganv::Port* src = NULL;
- Ganv::Port* dst = NULL;
+ Ganv::Port* src = nullptr;
+ Ganv::Port* dst = nullptr;
if (port1->is_output() && port2->is_input()) {
src = port1;
@@ -387,7 +388,7 @@ JackDriver::port_names(const PortID& id,
std::string& module_name,
std::string& port_name)
{
- jack_port_t* jack_port = NULL;
+ jack_port_t* jack_port = nullptr;
if (id.type == PortID::JACK_ID)
jack_port = jack_port_by_id(_client, id.id.jack_id);
@@ -413,7 +414,7 @@ JackDriver::port_names(const PortID& id,
bool
JackDriver::connect(PatchagePort* src_port, PatchagePort* dst_port)
{
- if (_client == NULL)
+ if (_client == nullptr)
return false;
int result = jack_connect(
@@ -437,7 +438,7 @@ bool
JackDriver::disconnect(PatchagePort* const src_port,
PatchagePort* const dst_port)
{
- if (_client == NULL)
+ if (_client == nullptr)
return false;
int result = jack_disconnect(
@@ -522,7 +523,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
JackDriver* me = reinterpret_cast<JackDriver*>(jack_driver);
me->_app->info_msg("Jack: Shutdown.");
Glib::Mutex::Lock lock(me->_shutdown_mutex);
- me->_client = NULL;
+ me->_client = nullptr;
me->_is_activated = false;
me->signal_detached.emit();
}
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index daaf7b9..5649950 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -45,7 +45,7 @@ public:
void attach(bool launch_daemon);
void detach();
- bool is_attached() const { return (_client != NULL); }
+ bool is_attached() const { return (_client != nullptr); }
bool is_realtime() const { return _client && jack_is_realtime(_client); }
void refresh();
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index b180f69..23498e6 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -112,10 +112,10 @@ struct ProjectList_column_record : public Gtk::TreeModel::ColumnRecord
Patchage::Patchage(int argc, char** argv)
: _xml(UIFile::open("patchage"))
#ifdef HAVE_ALSA
- , _alsa_driver(NULL)
+ , _alsa_driver(nullptr)
#endif
- , _jack_driver(NULL)
- , _conf(NULL)
+ , _jack_driver(nullptr)
+ , _conf(nullptr)
, INIT_WIDGET(_about_win)
, INIT_WIDGET(_main_scrolledwin)
, INIT_WIDGET(_main_win)
@@ -154,7 +154,7 @@ Patchage::Patchage(int argc, char** argv)
, INIT_WIDGET(_main_paned)
, INIT_WIDGET(_log_scrolledwindow)
, INIT_WIDGET(_status_text)
- , _legend(NULL)
+ , _legend(nullptr)
, _pane_initialized(false)
, _attach(true)
, _driver_detached(false)
@@ -311,7 +311,7 @@ Patchage::Patchage(int argc, char** argv)
_canvas->set_zoom(_conf->get_zoom());
_canvas->set_font_size(_conf->get_font_size());
if (_conf->get_sort_ports()) {
- _canvas->set_port_order(port_order, NULL);
+ _canvas->set_port_order(port_order, nullptr);
}
_main_win->resize(static_cast<int>(_conf->get_window_size().x),
@@ -373,7 +373,7 @@ Patchage::Patchage(int argc, char** argv)
#ifdef PATCHAGE_GTK_OSX
// Set up Mac menu bar
GtkosxApplication* osxapp =
- (GtkosxApplication*)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+ (GtkosxApplication*)g_object_new(GTKOSX_TYPE_APPLICATION, nullptr);
_menubar->hide();
_menu_file_quit->hide();
gtkosx_application_set_menu_bar(osxapp, GTK_MENU_SHELL(_menubar->gobj()));
@@ -382,7 +382,7 @@ Patchage::Patchage(int argc, char** argv)
g_signal_connect(_menubar->gobj(),
"can-activate-accel",
G_CALLBACK(can_activate_cb),
- NULL);
+ nullptr);
g_signal_connect(
osxapp, "NSApplicationWillTerminate", G_CALLBACK(terminate_cb), this);
gtkosx_application_ready(osxapp);
@@ -616,7 +616,7 @@ load_module_location(GanvNode* node, void* data)
void
Patchage::update_state()
{
- _canvas->for_each_node(load_module_location, NULL);
+ _canvas->for_each_node(load_module_location, nullptr);
}
/** Update the sensitivity status of menus to reflect the present.
@@ -731,7 +731,7 @@ Patchage::save_session(bool close)
path += '/';
jack_session_command_t* cmd =
jack_session_notify(_jack_driver->client(),
- NULL,
+ nullptr,
close ? JackSessionSaveAndQuit : JackSessionSave,
path.c_str());
@@ -841,7 +841,7 @@ void
Patchage::on_view_sort_ports()
{
const bool sort_ports = this->sort_ports();
- _canvas->set_port_order(sort_ports ? port_order : NULL, NULL);
+ _canvas->set_port_order(sort_ports ? port_order : nullptr, nullptr);
_conf->set_sort_ports(sort_ports);
refresh();
}
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index 6f6bbcf..0e5fef0 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -51,9 +51,9 @@ PatchageCanvas::find_module(const std::string& name, ModuleType type)
{
const ModuleIndex::const_iterator i = _module_index.find(name);
if (i == _module_index.end())
- return NULL;
+ return nullptr;
- PatchageModule* io_module = NULL;
+ PatchageModule* io_module = nullptr;
for (ModuleIndex::const_iterator j = i;
j != _module_index.end() && j->first == name;
++j) {
@@ -64,7 +64,7 @@ PatchageCanvas::find_module(const std::string& name, ModuleType type)
}
}
- // Return InputOutput module for Input or Output (or NULL if not found)
+ // Return InputOutput module for Input or Output (or nullptr if not found)
return io_module;
}
@@ -83,7 +83,7 @@ PatchageCanvas::remove_module(const std::string& name)
PatchagePort*
PatchageCanvas::find_port(const PortID& id)
{
- PatchagePort* pp = NULL;
+ PatchagePort* pp = nullptr;
PortIndex::iterator i = _port_index.find(id);
if (i != _port_index.end()) {
@@ -97,7 +97,7 @@ PatchageCanvas::find_port(const PortID& id)
jack_port_t* jack_port =
jack_port_by_id(_app->jack_driver()->client(), id.id.jack_id);
if (!jack_port)
- return NULL;
+ return nullptr;
std::string module_name;
std::string port_name;
@@ -197,7 +197,7 @@ PatchageCanvas::find_port_by_name(const std::string& client_name,
{
const ModuleIndex::const_iterator i = _module_index.find(client_name);
if (i == _module_index.end())
- return NULL;
+ return nullptr;
for (ModuleIndex::const_iterator j = i;
j != _module_index.end() && j->first == client_name;
@@ -207,7 +207,7 @@ PatchageCanvas::find_port_by_name(const std::string& client_name,
return port;
}
- return NULL;
+ return nullptr;
}
void
@@ -275,8 +275,8 @@ PatchageCanvas::add_module(const std::string& name, PatchageModule* module)
_module_index.insert(std::make_pair(name, module));
// Join partners, if applicable
- PatchageModule* in_module = NULL;
- PatchageModule* out_module = NULL;
+ PatchageModule* in_module = nullptr;
+ PatchageModule* out_module = nullptr;
if (module->type() == Input) {
in_module = module;
out_module = find_module(name, Output);
diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp
index 78f0829..a1b3f0a 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -45,16 +45,16 @@ PatchageEvent::execute(Patchage* patchage)
} else if (_type == CLIENT_CREATION) {
// No empty modules (for now)
g_free(_str);
- _str = NULL;
+ _str = nullptr;
} else if (_type == CLIENT_DESTRUCTION) {
patchage->canvas()->remove_module(_str);
g_free(_str);
- _str = NULL;
+ _str = nullptr;
} else if (_type == PORT_CREATION) {
- Driver* driver = NULL;
+ Driver* driver = nullptr;
if (_port_1.type == PortID::JACK_ID) {
#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
driver = patchage->jack_driver();
diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp
index 2c9efb4..3adae18 100644
--- a/src/PatchageEvent.hpp
+++ b/src/PatchageEvent.hpp
@@ -51,7 +51,7 @@ public:
};
explicit PatchageEvent(Type type = NULL_EVENT)
- : _str(NULL)
+ : _str(nullptr)
, _type(type)
{}
@@ -62,14 +62,14 @@ public:
template<typename P>
PatchageEvent(Type type, P port)
- : _str(NULL)
+ : _str(nullptr)
, _port_1(port)
, _type(type)
{}
template<typename P>
PatchageEvent(Type type, P port_1, P port_2)
- : _str(NULL)
+ : _str(nullptr)
, _port_1(port_1, false)
, _port_2(port_2, true)
, _type(type)
diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp
index cf2ba71..0b09a4f 100644
--- a/src/PatchageModule.cpp
+++ b/src/PatchageModule.cpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2010-2014 David Robillard <http://drobilla.net>
+ * Copyright 2010-2020 David Robillard <d@drobilla.net>
*
* Patchage is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
@@ -27,7 +27,7 @@ PatchageModule::PatchageModule(Patchage* app,
double y)
: Module(*app->canvas().get(), name, x, y)
, _app(app)
- , _menu(NULL)
+ , _menu(nullptr)
, _name(name)
, _type(type)
{
@@ -44,7 +44,7 @@ PatchageModule::~PatchageModule()
{
_app->canvas()->remove_module(this);
delete _menu;
- _menu = NULL;
+ _menu = nullptr;
}
void
@@ -153,5 +153,5 @@ PatchageModule::get_port(const std::string& name)
}
}
- return NULL;
+ return nullptr;
}
diff --git a/wscript b/wscript
index 35b3991..6f5374c 100644
--- a/wscript
+++ b/wscript
@@ -107,7 +107,6 @@ def configure(conf):
'-Wno-extra-semi-stmt',
'-Wno-old-style-cast',
'-Wno-weak-vtables',
- '-Wno-zero-as-null-pointer-constant',
],
'gcc': [
'-Wno-conditionally-supported',