diff options
-rw-r--r-- | .clang-format | 2 | ||||
-rw-r--r-- | .git-blame-ignore-revs | 8 | ||||
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | .reuse/dep5 | 5 | ||||
-rw-r--r-- | .suppress.cppcheck | 4 | ||||
-rw-r--r-- | doc/patchage.1 | 6 | ||||
-rw-r--r-- | lint/meson.build | 47 | ||||
-rw-r--r-- | meson.build | 89 | ||||
-rw-r--r-- | meson/suppressions/meson.build | 73 | ||||
-rw-r--r-- | meson_options.txt | 12 | ||||
-rwxr-xr-x | osx/bundleify.sh | 10 | ||||
-rw-r--r-- | src/AlsaDriver.cpp | 20 | ||||
-rw-r--r-- | src/Canvas.cpp | 18 | ||||
-rw-r--r-- | src/Canvas.hpp | 4 | ||||
-rw-r--r-- | src/CanvasModule.cpp | 4 | ||||
-rw-r--r-- | src/CanvasModule.hpp | 4 | ||||
-rw-r--r-- | src/CanvasPort.hpp | 4 | ||||
-rw-r--r-- | src/Configuration.cpp | 9 | ||||
-rw-r--r-- | src/Configuration.hpp | 4 | ||||
-rw-r--r-- | src/Drivers.cpp | 11 | ||||
-rw-r--r-- | src/Drivers.hpp | 4 | ||||
-rw-r--r-- | src/JackLibDriver.cpp | 5 | ||||
-rw-r--r-- | src/Legend.cpp | 1 | ||||
-rw-r--r-- | src/Patchage.cpp | 24 | ||||
-rw-r--r-- | src/Reactor.cpp | 6 | ||||
-rw-r--r-- | src/TextViewLog.cpp | 2 | ||||
-rw-r--r-- | src/UIFile.hpp | 7 | ||||
-rw-r--r-- | src/Widget.hpp | 2 | ||||
-rw-r--r-- | src/binary_location.h | 1 | ||||
-rw-r--r-- | src/handle_event.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 7 |
31 files changed, 209 insertions, 190 deletions
diff --git a/.clang-format b/.clang-format index 40d32ed..6daa06c 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,7 @@ --- AlignConsecutiveAssignments: true AlignConsecutiveDeclarations: true -AlignEscapedNewlinesLeft: true +AlignEscapedNewlines: Left BasedOnStyle: Mozilla BraceWrapping: AfterNamespace: false diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..698db8e --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,8 @@ +# Copyright 2025 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later + +# Format all code with clang-format +af5ec4bdda21e9a2f76f22050216a0b1cbbed575 + +# Format all code with clang-format +663a5d01b1931b97370ed8feff3ae229a9cc7ea4 @@ -1,4 +1,4 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2025 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later -build/ +/build/ diff --git a/.reuse/dep5 b/.reuse/dep5 index 0685ea3..44e287b 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -7,6 +7,11 @@ Files: .clant.json .includes.imp INSTALL.md NEWS Copyright: 2020-2021 David Robillard <d@drobilla.net> License: 0BSD OR GPL-3.0-or-later +Files: .suppress.cppcheck +Copyright: 2024 David Robillard <d@drobilla.net> +Comment: Contributed to the Commons as a tool configuration +License: 0BSD OR GPL-3.0-or-later + Files: AUTHORS README.md patchage.desktop.in Copyright: 2006-2014 David Robillard <d@drobilla.net> License: 0BSD OR GPL-3.0-or-later diff --git a/.suppress.cppcheck b/.suppress.cppcheck new file mode 100644 index 0000000..c03733a --- /dev/null +++ b/.suppress.cppcheck @@ -0,0 +1,4 @@ +constParameterCallback +constVariablePointer +missingReturn +normalCheckLevelMaxBranches diff --git a/doc/patchage.1 b/doc/patchage.1 index 3269561..b1654ee 100644 --- a/doc/patchage.1 +++ b/doc/patchage.1 @@ -1,8 +1,8 @@ .\" # Copyright 2010-2022 David Robillard <d@drobilla.net> .\" # SPDX-License-Identifier: CC-BY-SA-4.0 or GPL-3.0-or-later -.Dd Nov 30, 2022 +.Dd November 30, 2022 .Dt PATCHAGE 1 -.Os Patchage 1.0.11 +.Os .Sh NAME .Nm patchage .Nd graphically connect JACK/ALSA audio/MIDI applications @@ -43,4 +43,4 @@ exits with a status of 0, or non-zero if an error occurred. .Nm was written by .An David Robillard -.Mt d@drobilla.net . +.Aq Mt d@drobilla.net . diff --git a/lint/meson.build b/lint/meson.build new file mode 100644 index 0000000..48e736d --- /dev/null +++ b/lint/meson.build @@ -0,0 +1,47 @@ +# Copyright 2020-2024 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later + +if not meson.is_subproject() + # Check release metadata + autoship = find_program('autoship', required: false) + if autoship.found() + test( + 'autoship', + autoship, + args: ['test', patchage_src_root], + suite: 'data', + ) + endif + + # Check code with cppcheck + cppcheck = find_program('cppcheck', required: false) + if cppcheck.found() + compdb_path = join_paths(patchage_build_root, 'compile_commands.json') + suppress_path = join_paths(patchage_src_root, '.suppress.cppcheck') + test( + 'cppcheck', + cppcheck, + args: [ + '--enable=warning,style,performance,portability', + '--error-exitcode=1', + '--project=' + compdb_path, + '--suppressions-list=' + suppress_path, + '-DPATCHAGE_DISABLE_FMT_WARNINGS=', + '-q', + ], + suite: 'code', + timeout: 60, + ) + endif +endif + +# Check licensing metadata +reuse = find_program('reuse', required: false) +if reuse.found() + test( + 'REUSE', + reuse, + args: ['--root', patchage_src_root, 'lint'], + suite: 'data', + ) +endif diff --git a/meson.build b/meson.build index 32c79d4..9b4b6f2 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,7 @@ project( ) patchage_src_root = meson.current_source_dir() +patchage_build_root = meson.current_build_dir() major_version = meson.project_version().split('.')[0] version_suffix = '@0@-@1@'.format(meson.project_name(), major_version) @@ -25,11 +26,69 @@ version_suffix = '@0@-@1@'.format(meson.project_name(), major_version) # Required tools cpp = meson.get_compiler('cpp') -# Set global warning suppressions -subdir('meson/suppressions') -add_project_arguments(cpp_suppressions, language: ['cpp']) +# Configure fmt to be header-only with no compiled library add_project_arguments(['-DFMT_HEADER_ONLY'], language: ['cpp']) +# Set global warning suppressions +warning_level = get_option('warning_level') +cpp_suppressions = [] +if get_option('warning_level') == 'everything' + if cpp.get_id() == 'clang' + cpp_suppressions += [ + '-Wno-alloca', + '-Wno-c++20-compat', + '-Wno-c++98-compat', + '-Wno-c++98-compat-pedantic', + '-Wno-cast-function-type-strict', + '-Wno-cast-qual', + '-Wno-double-promotion', + '-Wno-float-conversion', + '-Wno-float-equal', + '-Wno-implicit-float-conversion', + '-Wno-padded', + '-Wno-pedantic', + '-Wno-shorten-64-to-32', + '-Wno-sign-conversion', + '-Wno-switch-default', + '-Wno-unsafe-buffer-usage', + '-Wno-weak-vtables', + ] + + if host_machine.system() == 'darwin' + cpp_suppressions += [ + '-Wno-documentation', # JACK + '-Wno-documentation-deprecated-sync', # JACK + '-Wno-documentation-unknown-command', # JACK + '-Wno-reserved-id-macro', # JACK + ] + endif + + elif cpp.get_id() == 'gcc' + cpp_suppressions += [ + '-Wno-abi-tag', + '-Wno-alloca', + '-Wno-conditionally-supported', + '-Wno-conversion', + '-Wno-effc++', + '-Wno-float-equal', + '-Wno-inline', + '-Wno-null-dereference', + '-Wno-padded', + '-Wno-pedantic', + '-Wno-stack-protector', + '-Wno-strict-overflow', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=noreturn', + '-Wno-suggest-attribute=pure', + '-Wno-suggest-final-methods', + '-Wno-suggest-final-types', + '-Wno-switch-default', + ] + endif +endif + +cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) + ########################## # Platform Configuration # ########################## @@ -256,29 +315,7 @@ install_man(files('doc/patchage.1')) ######### if get_option('lint') - if not meson.is_subproject() - # Check release metadata - autoship = find_program('autoship', required: false) - if autoship.found() - test( - 'autoship', - autoship, - args: ['test', patchage_src_root], - suite: 'data', - ) - endif - endif - - # Check licensing metadata - reuse = find_program('reuse', required: false) - if reuse.found() - test( - 'REUSE', - reuse, - args: ['--root', patchage_src_root, 'lint'], - suite: 'data', - ) - endif + subdir('lint') endif if not meson.is_subproject() diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build deleted file mode 100644 index 8c5a606..0000000 --- a/meson/suppressions/meson.build +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2020-2023 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later - -# Project-specific warning suppressions. -# -# This should be used in conjunction with the generic "warnings" sibling that -# enables all reasonable warnings for the compiler. It lives here just to keep -# the top-level meson.build more readable. - -####### -# C++ # -####### - -if is_variable('cpp') - cpp_suppressions = [] - - if get_option('warning_level') == 'everything' - if cpp.get_id() == 'clang' - cpp_suppressions += [ - '-Wno-alloca', - '-Wno-c++20-compat', - '-Wno-c++98-compat', - '-Wno-c++98-compat-pedantic', - '-Wno-cast-function-type-strict', - '-Wno-cast-qual', - '-Wno-double-promotion', - '-Wno-float-conversion', - '-Wno-float-equal', - '-Wno-implicit-float-conversion', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-shorten-64-to-32', - '-Wno-sign-conversion', - '-Wno-switch-default', - '-Wno-unsafe-buffer-usage', - '-Wno-weak-vtables', - ] - - if host_machine.system() == 'darwin' - cpp_suppressions += [ - '-Wno-documentation', # JACK - '-Wno-documentation-deprecated-sync', # JACK - '-Wno-documentation-unknown-command', # JACK - '-Wno-reserved-id-macro', # JACK - ] - endif - - elif cpp.get_id() == 'gcc' - cpp_suppressions += [ - '-Wno-abi-tag', - '-Wno-alloca', - '-Wno-conditionally-supported', - '-Wno-conversion', - '-Wno-effc++', - '-Wno-float-equal', - '-Wno-inline', - '-Wno-null-dereference', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-stack-protector', - '-Wno-strict-overflow', - '-Wno-suggest-attribute=const', - '-Wno-suggest-attribute=noreturn', - '-Wno-suggest-attribute=pure', - '-Wno-suggest-final-methods', - '-Wno-suggest-final-types', - '-Wno-switch-default', - ] - endif - endif - - cpp_suppressions = cpp.get_supported_arguments(cpp_suppressions) -endif diff --git a/meson_options.txt b/meson_options.txt index edc88cd..56d585b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,26 +1,20 @@ # Copyright 2022-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR GPL-3.0-or-later -option('alsa', type: 'feature', value: 'auto', yield: true, +option('alsa', type: 'feature', yield: true, description: 'Build ALSA sequencer support') option('checks', type: 'feature', value: 'enabled', yield: true, description: 'Check for platform-specific features') -option('jack', type: 'feature', value: 'auto', yield: true, +option('jack', type: 'feature', yield: true, description: 'Build JACK audio and MIDI support') -option('jack_dbus', type: 'feature', value: 'auto', yield: true, +option('jack_dbus', type: 'feature', yield: true, description: 'Use JACK via D-Bus') option('lint', type: 'boolean', value: false, yield: true, description: 'Run code quality checks') -option('strict', type: 'boolean', value: false, yield: true, - description: 'Enable ultra-strict warnings') - -option('tests', type: 'feature', value: 'auto', yield: true, - description: 'Build tests') - option('title', type: 'string', value: 'Patchage', description: 'Project title') diff --git a/osx/bundleify.sh b/osx/bundleify.sh index 559795b..665ff9d 100755 --- a/osx/bundleify.sh +++ b/osx/bundleify.sh @@ -36,7 +36,7 @@ done chmod -R 755 $bundle/Contents/lib/* # Copy libraries depended on by the executable to bundle -libs="`otool -L $exe | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//'`" +libs="$(otool -L $exe | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//')" for l in $libs; do cp $l $bundle/Contents/lib/; done @@ -48,7 +48,7 @@ while true; do # Copy all libraries this library depends on to bundle for l in $(find $bundle -name '*.dylib' -or -name '*.so'); do - reclibs="`otool -L $l | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//'`" + reclibs="$(otool -L $l | grep '\.dylib\|\.so' | grep '/User\|/usr/local' | sed 's/(.*//')" for rl in $reclibs; do cp $rl $bundle/Contents/lib/; done @@ -68,15 +68,15 @@ echo "Bundled libraries:" echo "$libs" for l in $libs; do - lname=`echo $l | sed 's/.*\///'` + lname=$(echo $l | sed 's/.*\///') lid="@executable_path/lib/$lname" lpath="$bundle/Contents/lib/$lname" install_name_tool -id $lid $lpath install_name_tool -change $l $lid $exe - for j in `find $bundle -name '*.so' -or -name '*.dylib'`; do + for j in $(find $bundle -name '*.so' -or -name '*.dylib'); do install_name_tool -change $l $lid $j done; done echo "External library references:" -otool -L $exe `find $bundle -name '*.so' -or -name '*.dylib'` | grep -v ':' | grep -v '@executable_path' | sort | uniq +otool -L $exe $(find $bundle -name '*.so' -or -name '*.dylib') | grep -v ':' | grep -v '@executable_path' | sort | uniq diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index 7671402..d320135 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -29,6 +29,7 @@ PATCHAGE_RESTORE_WARNINGS #include <memory> #include <optional> #include <set> +#include <string> #include <utility> #include <variant> @@ -133,10 +134,7 @@ AlsaDriver::AlsaDriver(ILog& log, EventSink emit_event) , _log(log) {} -AlsaDriver::~AlsaDriver() -{ - detach(); -} +AlsaDriver::~AlsaDriver() = default; void AlsaDriver::attach(bool /*launch_daemon*/) @@ -395,16 +393,16 @@ AlsaDriver::disconnect(const PortID& tail_id, const PortID& head_id) bool AlsaDriver::create_refresh_port() { - snd_seq_port_info_t* port_info = nullptr; - snd_seq_port_info_alloca(&port_info); - snd_seq_port_info_set_name(port_info, "System Announcement Receiver"); - snd_seq_port_info_set_type(port_info, SND_SEQ_PORT_TYPE_APPLICATION); - snd_seq_port_info_set_capability(port_info, + snd_seq_port_info_t* info = nullptr; + snd_seq_port_info_alloca(&info); + snd_seq_port_info_set_name(info, "System Announcement Receiver"); + snd_seq_port_info_set_type(info, SND_SEQ_PORT_TYPE_APPLICATION); + snd_seq_port_info_set_capability(info, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE | SND_SEQ_PORT_CAP_NO_EXPORT); - int ret = snd_seq_create_port(_seq, port_info); + int ret = snd_seq_create_port(_seq, info); if (ret) { _log.error( fmt::format("[ALSA] Error creating port ({})", snd_strerror(ret))); @@ -413,7 +411,7 @@ AlsaDriver::create_refresh_port() // Subscribe the port to the system announcer ret = snd_seq_connect_from(_seq, - snd_seq_port_info_get_port(port_info), + snd_seq_port_info_get_port(info), SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE); if (ret) { diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 5590a5b..ae8c51d 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -22,13 +22,13 @@ #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Canvas.hpp" -#include "ganv/Edge.hpp" -#include "ganv/Module.hpp" -#include "ganv/Node.hpp" -#include "ganv/Port.hpp" -#include "ganv/module.h" -#include "ganv/types.h" +#include <ganv/Canvas.hpp> +#include <ganv/Edge.hpp> +#include <ganv/Module.hpp> +#include <ganv/Node.hpp> +#include <ganv/Port.hpp> +#include <ganv/module.h> +#include <ganv/types.h> PATCHAGE_RESTORE_WARNINGS PATCHAGE_DISABLE_FMT_WARNINGS @@ -146,8 +146,8 @@ Canvas::create_port(Configuration& conf, Coord loc; if (!conf.get_module_location(client_name, module_type, loc)) { // No position saved, come up with a pseudo-random one - loc.x = static_cast<double>(20 + _rng() % 640); - loc.y = static_cast<double>(20 + _rng() % 480); + loc.x = static_cast<double>(20 + (_rng() % 640)); + loc.y = static_cast<double>(20 + (_rng() % 480)); conf.set_module_location(client_name, module_type, loc); } diff --git a/src/Canvas.hpp b/src/Canvas.hpp index ae713bc..5ab8a7e 100644 --- a/src/Canvas.hpp +++ b/src/Canvas.hpp @@ -10,8 +10,8 @@ #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Canvas.hpp" -#include "ganv/types.h" +#include <ganv/Canvas.hpp> +#include <ganv/types.h> PATCHAGE_RESTORE_WARNINGS #include <gdk/gdk.h> diff --git a/src/CanvasModule.cpp b/src/CanvasModule.cpp index 262cb18..43d2c8d 100644 --- a/src/CanvasModule.cpp +++ b/src/CanvasModule.cpp @@ -14,8 +14,8 @@ #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Module.hpp" -#include "ganv/Port.hpp" +#include <ganv/Module.hpp> +#include <ganv/Port.hpp> PATCHAGE_RESTORE_WARNINGS #include <gtkmm/menu.h> diff --git a/src/CanvasModule.hpp b/src/CanvasModule.hpp index e15a6b8..2ba7570 100644 --- a/src/CanvasModule.hpp +++ b/src/CanvasModule.hpp @@ -9,7 +9,7 @@ #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Module.hpp" +#include <ganv/Module.hpp> PATCHAGE_RESTORE_WARNINGS #include <gdk/gdk.h> @@ -52,7 +52,7 @@ public: CanvasPort* get_port(const PortID& id); SignalDirection type() const { return _type; } - ClientID id() const { return _id; } + const ClientID& id() const { return _id; } const std::string& name() const { return _name; } protected: diff --git a/src/CanvasPort.hpp b/src/CanvasPort.hpp index 0fc2f04..1210519 100644 --- a/src/CanvasPort.hpp +++ b/src/CanvasPort.hpp @@ -10,7 +10,7 @@ #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Port.hpp" +#include <ganv/Port.hpp> PATCHAGE_RESTORE_WARNINGS #include <gdk/gdk.h> @@ -90,7 +90,7 @@ public: } PortType type() const { return _type; } - PortID id() const { return _id; } + const PortID& id() const { return _id; } const std::string& name() const { return _name; } const std::string& human_name() const { return _human_name; } const std::optional<int>& order() const { return _order; } diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 86d60f8..f77f825 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -17,8 +17,6 @@ #include <utility> #include <vector> -// IWYU pragma: no_include <algorithm> - namespace patchage { namespace { @@ -252,7 +250,8 @@ Configuration::load() } } if (!found) { - std::cerr << "error: color for unknown port type `" << type_name << "'\n"; + std::cerr << "error: color for unknown port type `" << type_name + << "'\n"; } } else if (key == "module_position") { Coord loc; @@ -294,6 +293,8 @@ Configuration::load() file.close(); } +namespace { + inline void write_module_position(std::ofstream& os, const std::string& name, @@ -304,6 +305,8 @@ write_module_position(std::ofstream& os, << " " << type << " " << loc.x << " " << loc.y << "\n"; } +} // namespace + void Configuration::save() { diff --git a/src/Configuration.hpp b/src/Configuration.hpp index d956bd8..59039fc 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -13,6 +13,7 @@ #include <optional> #include <string> #include <tuple> +#include <utility> #include <variant> namespace patchage { @@ -74,8 +75,7 @@ public: // Set a global port color setting void set_setting(setting::PortColor new_setting) { - auto& color = _port_colors[static_cast<unsigned>(new_setting.type)]; - + const auto& color = _port_colors[static_cast<unsigned>(new_setting.type)]; if (color != new_setting.color) { set_port_color(new_setting.type, new_setting.color); } diff --git a/src/Drivers.cpp b/src/Drivers.cpp index 94efd14..7104b00 100644 --- a/src/Drivers.cpp +++ b/src/Drivers.cpp @@ -27,6 +27,17 @@ Drivers::Drivers(ILog& log, Driver::EventSink emit_event) })} {} +Drivers::~Drivers() +{ + if (_alsa_driver) { + _alsa_driver->detach(); + } + + if (_jack_driver) { + _jack_driver->detach(); + } +} + void Drivers::refresh() { diff --git a/src/Drivers.hpp b/src/Drivers.hpp index 6bb9eb4..a281d2e 100644 --- a/src/Drivers.hpp +++ b/src/Drivers.hpp @@ -4,13 +4,13 @@ #ifndef PATCHAGE_DRIVERS_HPP #define PATCHAGE_DRIVERS_HPP -#include "AudioDriver.hpp" #include "Driver.hpp" #include <memory> namespace patchage { +class AudioDriver; class ILog; enum class ClientType; @@ -26,7 +26,7 @@ public: Drivers(Drivers&&) = delete; Drivers& operator=(Drivers&&) = delete; - ~Drivers() = default; + ~Drivers(); /// Refresh all drivers and emit results to the event sink void refresh(); diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp index 6df5b02..b540347 100644 --- a/src/JackLibDriver.cpp +++ b/src/JackLibDriver.cpp @@ -104,10 +104,7 @@ JackLibDriver::JackLibDriver(ILog& log, EventSink emit_event) , _log{log} {} -JackLibDriver::~JackLibDriver() -{ - detach(); -} +JackLibDriver::~JackLibDriver() = default; void JackLibDriver::attach(const bool launch_daemon) diff --git a/src/Legend.cpp b/src/Legend.cpp index 0733e2f..ff0f7fe 100644 --- a/src/Legend.cpp +++ b/src/Legend.cpp @@ -9,7 +9,6 @@ #include "patchage_config.h" #include <gdkmm/color.h> -#include <glibmm/signalproxy.h> #include <glibmm/ustring.h> #include <gtkmm/box.h> #include <gtkmm/colorbutton.h> diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 82c12df..349fbf0 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -24,16 +24,15 @@ #include "event_to_string.hpp" #include "handle_event.hpp" #include "i18n.hpp" -#include "patchage_config.h" // IWYU pragma: keep #include "warnings.hpp" PATCHAGE_DISABLE_GANV_WARNINGS -#include "ganv/Edge.hpp" -#include "ganv/Module.hpp" -#include "ganv/Node.hpp" -#include "ganv/Port.hpp" -#include "ganv/module.h" -#include "ganv/types.h" +#include <ganv/Edge.hpp> +#include <ganv/Module.hpp> +#include <ganv/Node.hpp> +#include <ganv/Port.hpp> +#include <ganv/module.h> +#include <ganv/types.h> PATCHAGE_RESTORE_WARNINGS PATCHAGE_DISABLE_FMT_WARNINGS @@ -46,7 +45,6 @@ PATCHAGE_RESTORE_WARNINGS #include <glibmm/main.h> #include <glibmm/miscutils.h> #include <glibmm/propertyproxy.h> -#include <glibmm/signalproxy.h> #include <glibmm/ustring.h> #include <gobject/gclosure.h> #include <gtk/gtk.h> @@ -172,8 +170,7 @@ update_labels(GanvNode* node, void* data) const bool human_names = *static_cast<const bool*>(data); if (GANV_IS_MODULE(node)) { Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); - auto* pmod = dynamic_cast<CanvasModule*>(gmod); - if (pmod) { + if (dynamic_cast<const CanvasModule*>(gmod)) { for (Ganv::Port* gport : *gmod) { auto* pport = dynamic_cast<CanvasPort*>(gport); if (pport) { @@ -205,12 +202,11 @@ update_port_colors(GanvNode* node, void* data) } Ganv::Module* gmod = Glib::wrap(GANV_MODULE(node)); - auto* pmod = dynamic_cast<CanvasModule*>(gmod); - if (!pmod) { + if (!dynamic_cast<CanvasModule*>(gmod)) { return; } - for (Ganv::Port* p : *pmod) { + for (Ganv::Port* p : *gmod) { auto* port = dynamic_cast<CanvasPort*>(p); if (port) { const uint32_t rgba = patchage->conf().get_port_color(port->type()); @@ -227,7 +223,7 @@ update_edge_color(GanvEdge* edge, void* data) Ganv::Edge* edgemm = Glib::wrap(edge); if (edgemm) { - auto* tail = dynamic_cast<CanvasPort*>((edgemm)->get_tail()); + const auto* tail = dynamic_cast<const CanvasPort*>((edgemm)->get_tail()); if (tail) { edgemm->set_color(patchage->conf().get_port_color(tail->type())); } diff --git a/src/Reactor.cpp b/src/Reactor.cpp index 7163539..eb7300e 100644 --- a/src/Reactor.cpp +++ b/src/Reactor.cpp @@ -17,7 +17,7 @@ #include "SignalDirection.hpp" #include "warnings.hpp" -#include "ganv/Port.hpp" +#include <ganv/Port.hpp> PATCHAGE_DISABLE_FMT_WARNINGS #include <fmt/core.h> @@ -191,11 +191,11 @@ Reactor::module_name(const ClientID& client) { // Note that split modules always have the same name - if (CanvasModule* mod = find_module(client, SignalDirection::input)) { + if (const CanvasModule* mod = find_module(client, SignalDirection::input)) { return mod->name(); } - if (CanvasModule* mod = find_module(client, SignalDirection::output)) { + if (const CanvasModule* mod = find_module(client, SignalDirection::output)) { return mod->name(); } diff --git a/src/TextViewLog.cpp b/src/TextViewLog.cpp index ba7c512..ad20c37 100644 --- a/src/TextViewLog.cpp +++ b/src/TextViewLog.cpp @@ -76,7 +76,7 @@ TextViewLog::min_height() const int line_height = 0; _text_view->get_line_yrange(buffer->begin(), y, line_height); - return line_height + 2 * _text_view->get_pixels_inside_wrap(); + return line_height + (2 * _text_view->get_pixels_inside_wrap()); } } // namespace patchage diff --git a/src/UIFile.hpp b/src/UIFile.hpp index cd07aad..1f2c39f 100644 --- a/src/UIFile.hpp +++ b/src/UIFile.hpp @@ -13,9 +13,7 @@ #include <glibmm/refptr.h> #include <gtkmm/builder.h> -#include <fstream> #include <iostream> -#include <sstream> #include <stdexcept> #include <string> @@ -53,10 +51,7 @@ public: return Gtk::Builder::create_from_file(ui_filename); } - std::stringstream ss; - ss << "Unable to find " << ui_filename << "\n"; - throw std::runtime_error(ss.str()); - return {}; + throw std::runtime_error("Unable to find " + ui_filename); } }; diff --git a/src/Widget.hpp b/src/Widget.hpp index 1c3b6ee..0f813da 100644 --- a/src/Widget.hpp +++ b/src/Widget.hpp @@ -5,7 +5,7 @@ #define PATCHAGE_WIDGET_HPP #include <glibmm/refptr.h> -#include <gtkmm/builder.h> // IWYU pragma: keep +#include <gtkmm/builder.h> #include <string> diff --git a/src/binary_location.h b/src/binary_location.h index 12f726e..e298775 100644 --- a/src/binary_location.h +++ b/src/binary_location.h @@ -3,7 +3,6 @@ #include <dlfcn.h> -#include <climits> #include <cstdlib> #include <string> diff --git a/src/handle_event.cpp b/src/handle_event.cpp index d75c42d..4564a27 100644 --- a/src/handle_event.cpp +++ b/src/handle_event.cpp @@ -79,7 +79,7 @@ public: { _metadata.set_port(event.id, event.info); - auto* const port = + const auto* const port = _canvas.create_port(_conf, _metadata, event.id, event.info); if (!port) { diff --git a/src/main.cpp b/src/main.cpp index 0f4d1b0..289242f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,9 +75,9 @@ print_usage() std::cout << "Usage: patchage [OPTION]...\n"; std::cout << "Visually connect JACK and ALSA Audio and MIDI ports.\n\n"; std::cout << "Options:\n"; - std::cout << " -h, --help Display this help and exit.\n"; - std::cout << " -A, --no-alsa Do not automatically attach to ALSA.\n"; - std::cout << " -J, --no-jack Do not automatically attack to JACK.\n"; + std::cout << " -h, --help Display this help and exit\n"; + std::cout << " -A, --no-alsa Do not automatically attach to ALSA\n"; + std::cout << " -J, --no-jack Do not automatically attack to JACK\n"; } void @@ -146,7 +146,6 @@ main(int argc, char** argv) patchage::Patchage patchage(options); Gtk::Main::run(*patchage.window()); patchage.save(); - } catch (std::exception& e) { std::cerr << "patchage: error: " << e.what() << "\n"; return 1; |