From df897ef5b01a045769ffb71ebc6dead179db857c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Aug 2020 14:15:38 +0200 Subject: Use nullptr for empty smart pointers --- include/ingen/DataAccess.hpp | 4 ++-- include/ingen/InstanceAccess.hpp | 4 ++-- include/ingen/Interface.hpp | 2 +- include/ingen/LV2Features.hpp | 2 +- include/ingen/client/SocketClient.hpp | 2 +- src/World.cpp | 2 +- src/client/ClientStore.cpp | 4 ++-- src/client/GraphModel.cpp | 2 +- src/client/PluginModel.cpp | 2 +- src/client/PluginUI.cpp | 4 ++-- src/gui/App.cpp | 2 +- src/gui/BreadCrumbs.cpp | 8 +++----- src/gui/BreadCrumbs.hpp | 4 ++-- src/gui/ConnectWindow.cpp | 2 +- src/gui/GraphBox.cpp | 2 +- src/gui/WindowFactory.hpp | 2 +- src/server/CompiledGraph.cpp | 2 +- src/server/Engine.cpp | 4 ++-- src/server/GraphImpl.cpp | 2 +- src/server/LV2Block.cpp | 8 ++++---- src/server/LV2ResizeFeature.hpp | 5 +++-- src/server/PreProcessContext.hpp | 2 +- src/server/Worker.cpp | 2 +- src/server/ingen_lv2.cpp | 4 ++-- 24 files changed, 38 insertions(+), 39 deletions(-) diff --git a/include/ingen/DataAccess.hpp b/include/ingen/DataAccess.hpp index b06c8dec..49bb6102 100644 --- a/include/ingen/DataAccess.hpp +++ b/include/ingen/DataAccess.hpp @@ -44,12 +44,12 @@ struct DataAccess : public ingen::LV2Features::Feature SPtr feature(World& world, Node* node) override { Node* store_node = world.store()->get(node->path()); if (!store_node) { - return SPtr(); + return nullptr; } LilvInstance* inst = store_node->instance(); if (!inst) { - return SPtr(); + return nullptr; } const LV2_Descriptor* desc = lilv_instance_get_descriptor(inst); diff --git a/include/ingen/InstanceAccess.hpp b/include/ingen/InstanceAccess.hpp index 4d67d8db..500f4902 100644 --- a/include/ingen/InstanceAccess.hpp +++ b/include/ingen/InstanceAccess.hpp @@ -37,12 +37,12 @@ struct InstanceAccess : public ingen::LV2Features::Feature SPtr feature(World& world, Node* node) override { Node* store_node = world.store()->get(node->path()); if (!store_node) { - return SPtr(); + return nullptr; } LilvInstance* instance = store_node->instance(); if (!instance) { - return SPtr(); + return nullptr; } return std::make_shared( diff --git a/include/ingen/Interface.hpp b/include/ingen/Interface.hpp index 8a87af8b..98c0d4cd 100644 --- a/include/ingen/Interface.hpp +++ b/include/ingen/Interface.hpp @@ -55,7 +55,7 @@ public: virtual URI uri() const = 0; - virtual SPtr respondee() const { return SPtr(); } + virtual SPtr respondee() const { return nullptr; } virtual void set_respondee(const SPtr& respondee) {} diff --git a/include/ingen/LV2Features.hpp b/include/ingen/LV2Features.hpp index ae201bf6..792ee9d9 100644 --- a/include/ingen/LV2Features.hpp +++ b/include/ingen/LV2Features.hpp @@ -57,7 +57,7 @@ protected: const char* uri() const override { return _uri; } SPtr feature(World& world, Node* block) override { - return SPtr(); + return nullptr; } const char* _uri; diff --git a/include/ingen/client/SocketClient.hpp b/include/ingen/client/SocketClient.hpp index 8e551821..642ae1ef 100644 --- a/include/ingen/client/SocketClient.hpp +++ b/include/ingen/client/SocketClient.hpp @@ -59,7 +59,7 @@ public: if (!sock->connect(uri)) { world.log().error("Failed to connect <%1%> (%2%)\n", sock->uri(), strerror(errno)); - return SPtr(); + return nullptr; } return SPtr(new SocketClient(world, uri, sock, respondee)); } diff --git a/src/World.cpp b/src/World.cpp index 4b502e6e..6df3b4b1 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -305,7 +305,7 @@ World::new_interface(const URI& engine_uri, const SPtr& respondee) _impl->interface_factories.find(std::string(engine_uri.scheme())); if (i == _impl->interface_factories.end()) { log().warn("Unknown URI scheme `%1%'\n", engine_uri.scheme()); - return SPtr(); + return nullptr; } return i->second(*this, engine_uri, respondee); diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index a02a3227..a9d8f44b 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -96,7 +96,7 @@ ClientStore::remove_object(const Raul::Path& path) // Find the object, the "top" of the tree to remove const iterator top = find(path); if (top == end()) { - return SPtr(); + return nullptr; } auto object = std::dynamic_pointer_cast(top->second); @@ -158,7 +158,7 @@ ClientStore::_object(const Raul::Path& path) { const iterator i = find(path); if (i == end()) { - return SPtr(); + return nullptr; } else { auto model = std::dynamic_pointer_cast(i->second); assert(model); diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index 4de2cb53..b965258e 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -105,7 +105,7 @@ GraphModel::get_arc(const Node* tail, const Node* head) if (i != _arcs.end()) { return std::dynamic_pointer_cast(i->second); } else { - return SPtr(); + return nullptr; } } diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index f72d8a3a..b3a9aecd 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -245,7 +245,7 @@ SPtr PluginModel::ui(ingen::World& world, const SPtr& block) const { if (!_lilv_plugin) { - return SPtr(); + return nullptr; } return PluginUI::create(world, block, _lilv_plugin); diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 1074be3e..b0f92e41 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -40,7 +40,7 @@ get_port(PluginUI* ui, uint32_t port_index) ui->world().log().error("%1% UI tried to access invalid port %2%\n", ui->block()->plugin()->uri().c_str(), port_index); - return SPtr(); + return nullptr; } return ui->block()->ports()[port_index]; } @@ -211,7 +211,7 @@ PluginUI::create(ingen::World& world, if (!ui) { lilv_node_free(gtk_ui); - return SPtr(); + return nullptr; } // Create the PluginUI, but don't instantiate yet diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 4be4bbd5..c5727617 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -202,7 +202,7 @@ App::detach() _loader.reset(); _store.reset(); _client.reset(); - _world.set_interface(SPtr()); + _world.set_interface(nullptr); } } diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index 5dbdab17..b75c8670 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -49,7 +49,7 @@ BreadCrumbs::view(const Raul::Path& path) } } - return SPtr(); + return nullptr; } /** Sets up the crumbs to display `path`. @@ -158,10 +158,8 @@ BreadCrumbs::build(const Raul::Path& path, const SPtr& view) BreadCrumbs::BreadCrumb* BreadCrumbs::create_crumb(const Raul::Path& path, const SPtr& view) { - BreadCrumb* but = manage( - new BreadCrumb(path, - ((view && path == view->graph()->path()) - ? view : SPtr()))); + BreadCrumb* but = manage(new BreadCrumb( + path, ((view && path == view->graph()->path()) ? view : nullptr))); but->signal_toggled().connect( sigc::bind(sigc::mem_fun(this, &BreadCrumbs::breadcrumb_clicked), diff --git a/src/gui/BreadCrumbs.hpp b/src/gui/BreadCrumbs.hpp index d62a7ee0..6f42e573 100644 --- a/src/gui/BreadCrumbs.hpp +++ b/src/gui/BreadCrumbs.hpp @@ -65,7 +65,7 @@ private: { public: BreadCrumb(const Raul::Path& path, - const SPtr& view = SPtr()) + const SPtr& view = nullptr) : _path(path) , _view(view) { @@ -103,7 +103,7 @@ private: }; BreadCrumb* create_crumb(const Raul::Path& path, - const SPtr& view = SPtr()); + const SPtr& view = nullptr); void breadcrumb_clicked(BreadCrumb* crumb); diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 16e88235..3e5e5d7c 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -292,7 +292,7 @@ ConnectWindow::disconnect() _attached = false; _app->detach(); - set_connected_to(SPtr()); + set_connected_to(nullptr); if (!_widgets_loaded) { return; diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 56bb45d2..571bc61a 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -197,7 +197,7 @@ GraphBox::create(App& app, const SPtr& graph) Glib::RefPtr xml = WidgetFactory::create("graph_win"); xml->get_widget_derived("graph_win_vbox", result); result->init_box(app); - result->set_graph(graph, SPtr()); + result->set_graph(graph, nullptr); if (app.is_plugin()) { result->_menu_close->set_sensitive(false); diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp index 77d84ac6..5b1a6984 100644 --- a/src/gui/WindowFactory.hpp +++ b/src/gui/WindowFactory.hpp @@ -63,7 +63,7 @@ public: void present_graph( SPtr graph, GraphWindow* preferred = nullptr, - SPtr view = SPtr()); + SPtr view = nullptr); void present_load_plugin(SPtr graph, Properties data=Properties()); void present_load_graph(SPtr graph, Properties data=Properties()); diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index ba4cc11e..3c6b6172 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -82,7 +82,7 @@ CompiledGraph::compile(Raul::Maid& maid, GraphImpl& graph) } else { log.error("Feedback compiling %1%\n", e.node->path()); } - return MPtr(); + return nullptr; } } diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index ae5b297f..efc152d5 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -169,7 +169,7 @@ Engine::~Engine() store->clear(); } - _world.set_store(SPtr()); + _world.set_store(nullptr); } void @@ -406,7 +406,7 @@ Engine::activate() enqueue_event( new events::CreateGraph( - *this, SPtr(), -1, 0, Raul::Path("/"), properties)); + *this, nullptr, -1, 0, Raul::Path("/"), properties)); flush_events(std::chrono::milliseconds(10)); if (!_root_graph) { diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index 08c8ccc6..4d1d7856 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -292,7 +292,7 @@ GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port) _arcs.erase(i); return arc; } else { - return SPtr(); + return nullptr; } } diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index c555ac4a..7855a0f1 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -90,7 +90,7 @@ LV2Block::make_instance(URIs& uris, if (!inst) { engine.log().error("Failed to instantiate <%1%>\n", _lv2_plugin->uri().c_str()); - return SPtr(); + return nullptr; } const LV2_Options_Interface* options_iface = nullptr; @@ -148,7 +148,7 @@ LV2Block::make_instance(URIs& uris, "%1% auto-morphed to unknown type %2%\n", port->path().c_str(), type); - return SPtr(); + return nullptr; } } else { parent_graph()->engine().log().error( @@ -178,7 +178,7 @@ LV2Block::prepare_poly(BufferFactory& bufs, uint32_t poly) const SampleRate rate = bufs.engine().sample_rate(); assert(!_prepared_instances); _prepared_instances = bufs.maid().make_managed( - poly, *_instances, SPtr()); + poly, *_instances, nullptr); for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) { SPtr inst = make_instance(bufs.uris(), rate, i, true); if (!inst) { @@ -436,7 +436,7 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) // Actually create plugin instances and port buffers. const SampleRate rate = bufs.engine().sample_rate(); _instances = bufs.maid().make_managed( - _polyphony, SPtr()); + _polyphony, nullptr); for (uint32_t i = 0; i < _polyphony; ++i) { _instances->at(i) = make_instance(bufs.uris(), rate, i, false); if (!_instances->at(i)) { diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp index 1bd93ee0..322aacb8 100644 --- a/src/server/LV2ResizeFeature.hpp +++ b/src/server/LV2ResizeFeature.hpp @@ -46,8 +46,9 @@ struct ResizeFeature : public ingen::LV2Features::Feature { SPtr feature(World& w, Node* n) { BlockImpl* block = dynamic_cast(n); - if (!block) - return SPtr(); + if (!block) { + return nullptr; + } LV2_Resize_Port_Resize* data = (LV2_Resize_Port_Resize*)malloc(sizeof(LV2_Resize_Port_Resize)); data->data = block; diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp index 7579e1e2..a1bdbb5f 100644 --- a/src/server/PreProcessContext.hpp +++ b/src/server/PreProcessContext.hpp @@ -67,7 +67,7 @@ public: if (must_compile(graph)) { return compile(maid, graph); } - return MPtr(); + return nullptr; } /** Return all graphs that require compilation after an atomic bundle. */ diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp index 69f9eec6..1180fa47 100644 --- a/src/server/Worker.cpp +++ b/src/server/Worker.cpp @@ -96,7 +96,7 @@ Worker::Schedule::feature(World&, Node* n) { auto* block = dynamic_cast(n); if (!block) { - return SPtr(); + return nullptr; } auto* data = static_cast(malloc(sizeof(LV2_Worker_Schedule))); diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index a50b5859..e5abcc92 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -672,8 +672,8 @@ static void ingen_cleanup(LV2_Handle instance) { auto* me = static_cast(instance); - me->world->set_engine(SPtr()); - me->world->set_interface(SPtr()); + me->world->set_engine(nullptr); + me->world->set_interface(nullptr); if (me->main) { me->main->join(); me->main.reset(); -- cgit v1.2.1