From 68c9d227d041b2993ee9e4be29d7de583195d73c Mon Sep 17 00:00:00 2001 From: Matt Kline Date: Sun, 6 May 2018 16:32:10 -0700 Subject: [PATCH] Default some empty destructors Moving empty destructors out of the .cpp files and into headers allows them to be devirtualized in certain cases. (When the compiler can't "see" a function in a header, it must largely assume it's some black box that the linker will resolve.) While we're at it, use C++11's `= default` to define empty virtual desturctors for us. For some classes (e.g., Piano), nothing is derived from it, so we can mark the class as final and remove any explicit virtual dtor. There are many other places where this can be done, but this is a large enough patch as-is. --- include/AutomatableModelView.h | 2 +- include/AutomationPattern.h | 2 +- include/AutomationTrack.h | 4 ++-- include/BBTrack.h | 4 ++-- include/Fader.h | 2 +- include/FileBrowser.h | 4 ++-- include/Graph.h | 4 ++-- include/Instrument.h | 2 +- include/LcdSpinBox.h | 2 +- include/Pattern.h | 2 +- include/Piano.h | 3 +-- include/PianoView.h | 2 +- include/SampleTrack.h | 3 +-- include/TabBar.h | 2 +- include/TabWidget.h | 2 +- include/TimeDisplayWidget.h | 2 +- include/ToolButton.h | 2 +- src/core/AutomationPattern.cpp | 10 ---------- src/core/Instrument.cpp | 10 ---------- src/core/Piano.cpp | 13 ------------- src/gui/AutomatableModelView.cpp | 10 ---------- src/gui/FileBrowser.cpp | 20 -------------------- src/gui/PianoView.cpp | 13 ------------- src/gui/widgets/Fader.cpp | 6 ------ src/gui/widgets/Graph.cpp | 15 --------------- src/gui/widgets/LcdSpinBox.cpp | 8 -------- src/gui/widgets/SideBar.cpp | 5 ++--- src/gui/widgets/TabBar.cpp | 10 ---------- src/gui/widgets/TabWidget.cpp | 6 ------ src/gui/widgets/TimeDisplayWidget.cpp | 11 ----------- src/gui/widgets/ToolButton.cpp | 7 ------- src/tracks/AutomationTrack.cpp | 20 -------------------- src/tracks/BBTrack.cpp | 20 -------------------- src/tracks/Pattern.cpp | 13 ------------- src/tracks/SampleTrack.cpp | 10 ---------- 35 files changed, 23 insertions(+), 228 deletions(-) diff --git a/include/AutomatableModelView.h b/include/AutomatableModelView.h index ead5d81af..3b320434f 100644 --- a/include/AutomatableModelView.h +++ b/include/AutomatableModelView.h @@ -36,7 +36,7 @@ class EXPORT AutomatableModelView : public ModelView { public: AutomatableModelView( Model* model, QWidget* _this ); - virtual ~AutomatableModelView(); + virtual ~AutomatableModelView() = default; // some basic functions for convenience AutomatableModel* modelUntyped() diff --git a/include/AutomationPattern.h b/include/AutomationPattern.h index 0af7ea4fa..89dcfed7c 100644 --- a/include/AutomationPattern.h +++ b/include/AutomationPattern.h @@ -54,7 +54,7 @@ public: AutomationPattern( AutomationTrack * _auto_track ); AutomationPattern( const AutomationPattern & _pat_to_copy ); - virtual ~AutomationPattern(); + virtual ~AutomationPattern() = default; bool addObject( AutomatableModel * _obj, bool _search_dup = true ); diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index 733f5941c..195c21e9d 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -35,7 +35,7 @@ class AutomationTrack : public Track Q_OBJECT public: AutomationTrack( TrackContainer* tc, bool _hidden = false ); - virtual ~AutomationTrack(); + virtual ~AutomationTrack() = default; virtual bool play( const MidiTime & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num = -1 ); @@ -63,7 +63,7 @@ class AutomationTrackView : public TrackView { public: AutomationTrackView( AutomationTrack* at, TrackContainerView* tcv ); - virtual ~AutomationTrackView(); + virtual ~AutomationTrackView() = default; virtual void dragEnterEvent( QDragEnterEvent * _dee ); virtual void dropEvent( QDropEvent * _de ); diff --git a/include/BBTrack.h b/include/BBTrack.h index aafeeaf71..9e72c4f04 100644 --- a/include/BBTrack.h +++ b/include/BBTrack.h @@ -41,7 +41,7 @@ class BBTCO : public TrackContentObject { public: BBTCO( Track * _track ); - virtual ~BBTCO(); + virtual ~BBTCO() = default; virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); @@ -90,7 +90,7 @@ class BBTCOView : public TrackContentObjectView Q_OBJECT public: BBTCOView( TrackContentObject * _tco, TrackView * _tv ); - virtual ~BBTCOView(); + virtual ~BBTCOView() = default; QColor color() const { diff --git a/include/Fader.h b/include/Fader.h index be165f234..80359b4c6 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -68,7 +68,7 @@ public: Fader( FloatModel * _model, const QString & _name, QWidget * _parent ); Fader( FloatModel * _model, const QString & _name, QWidget * _parent, QPixmap * back, QPixmap * leds, QPixmap * knob ); - virtual ~Fader(); + virtual ~Fader() = default; void init(FloatModel * model, QString const & name); diff --git a/include/FileBrowser.h b/include/FileBrowser.h index f3daa48d1..91a58831d 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -51,7 +51,7 @@ public: FileBrowser( const QString & directories, const QString & filter, const QString & title, const QPixmap & pm, QWidget * parent, bool dirs_as_items = false, bool recurse = false ); - virtual ~FileBrowser(); + virtual ~FileBrowser() = default; private slots: void reloadTree( void ); @@ -85,7 +85,7 @@ class FileBrowserTreeWidget : public QTreeWidget Q_OBJECT public: FileBrowserTreeWidget( QWidget * parent ); - virtual ~FileBrowserTreeWidget(); + virtual ~FileBrowserTreeWidget() = default; protected: diff --git a/include/Graph.h b/include/Graph.h index 71e6da60b..dc1d1fe16 100644 --- a/include/Graph.h +++ b/include/Graph.h @@ -55,7 +55,7 @@ public: int _width = 132, int _height = 104 ); - virtual ~Graph(); + virtual ~Graph() = default; void setForeground( const QPixmap & _pixmap ); @@ -122,7 +122,7 @@ public: bool _default_constructed = false, float _step = 0.0 ); - virtual ~graphModel(); + virtual ~graphModel() = default; // TODO: saveSettings, loadSettings? diff --git a/include/Instrument.h b/include/Instrument.h index 9dd68ef98..ec7245dce 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -57,7 +57,7 @@ public: Instrument( InstrumentTrack * _instrument_track, const Descriptor * _descriptor ); - virtual ~Instrument(); + virtual ~Instrument() = default; // -------------------------------------------------------------------- // functions that can/should be re-implemented: diff --git a/include/LcdSpinBox.h b/include/LcdSpinBox.h index 0bac3ddc0..d6896f52b 100644 --- a/include/LcdSpinBox.h +++ b/include/LcdSpinBox.h @@ -38,7 +38,7 @@ public: LcdSpinBox( int numDigits, const QString& style, QWidget* parent, const QString& name = QString::null ); - virtual ~LcdSpinBox(); + virtual ~LcdSpinBox() = default; virtual void modelChanged() { diff --git a/include/Pattern.h b/include/Pattern.h index 189631412..235f504c4 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -163,7 +163,7 @@ class PatternView : public TrackContentObjectView public: PatternView( Pattern* pattern, TrackView* parent ); - virtual ~PatternView(); + virtual ~PatternView() = default; Q_PROPERTY(QColor noteFillColor READ getNoteFillColor WRITE setNoteFillColor) Q_PROPERTY(QColor noteBorderColor READ getNoteBorderColor WRITE setNoteBorderColor) diff --git a/include/Piano.h b/include/Piano.h index 1515d267d..633236f4a 100644 --- a/include/Piano.h +++ b/include/Piano.h @@ -31,7 +31,7 @@ class InstrumentTrack; class MidiEventProcessor; -class Piano : public Model +class Piano final : public Model { public: enum KeyTypes @@ -41,7 +41,6 @@ public: } ; Piano( InstrumentTrack* track ); - virtual ~Piano(); void setKeyState( int key, bool state ); diff --git a/include/PianoView.h b/include/PianoView.h index 935279a98..2a362c584 100644 --- a/include/PianoView.h +++ b/include/PianoView.h @@ -38,7 +38,7 @@ class PianoView : public QWidget, public ModelView Q_OBJECT public: PianoView( QWidget * _parent ); - virtual ~PianoView(); + virtual ~PianoView() = default; static int getKeyFromKeyEvent( QKeyEvent * _ke ); diff --git a/include/SampleTrack.h b/include/SampleTrack.h index 6d39ed355..decf52f3f 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -98,8 +98,7 @@ class SampleTCOView : public TrackContentObjectView public: SampleTCOView( SampleTCO * _tco, TrackView * _tv ); - virtual ~SampleTCOView(); - + virtual ~SampleTCOView() = default; public slots: void updateSample(); diff --git a/include/TabBar.h b/include/TabBar.h index 56900fda4..4ef0b1ac7 100644 --- a/include/TabBar.h +++ b/include/TabBar.h @@ -42,7 +42,7 @@ class EXPORT TabBar : public QWidget public: TabBar( QWidget * _parent, QBoxLayout::Direction _dir = QBoxLayout::LeftToRight ); - virtual ~TabBar(); + virtual ~TabBar() = default; TabButton * addTab( QWidget * _w, const QString & _text, int _id, bool _add_stretch = false, diff --git a/include/TabWidget.h b/include/TabWidget.h index 402d7c9cc..dacd2648b 100644 --- a/include/TabWidget.h +++ b/include/TabWidget.h @@ -37,7 +37,7 @@ class TabWidget : public QWidget Q_OBJECT public: TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false ); - virtual ~TabWidget(); + virtual ~TabWidget() = default; void addTab( QWidget * w, const QString & name, const char *pixmap = NULL, int idx = -1 ); diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 67ae4d6ca..175f159c9 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -37,7 +37,7 @@ class TimeDisplayWidget : public QWidget Q_OBJECT public: TimeDisplayWidget(); - virtual ~TimeDisplayWidget(); + virtual ~TimeDisplayWidget() = default; protected: diff --git a/include/ToolButton.h b/include/ToolButton.h index 62901f590..196ec48f0 100644 --- a/include/ToolButton.h +++ b/include/ToolButton.h @@ -42,7 +42,7 @@ public: QToolButton(_parent) { } - virtual ~ToolButton(); + virtual ~ToolButton() = default; } ; diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 32b13f3f4..9345ad566 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -98,16 +98,6 @@ AutomationPattern::AutomationPattern( const AutomationPattern & _pat_to_copy ) : } } - - - -AutomationPattern::~AutomationPattern() -{ -} - - - - bool AutomationPattern::addObject( AutomatableModel * _obj, bool _search_dup ) { if( _search_dup && m_objects.contains(_obj) ) diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index 859882fd3..534bb783a 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -34,16 +34,6 @@ Instrument::Instrument( InstrumentTrack * _instrument_track, { } - - - -Instrument::~Instrument() -{ -} - - - - void Instrument::play( sampleFrame * ) { } diff --git a/src/core/Piano.cpp b/src/core/Piano.cpp index 7ea9cb2b0..565f1aa4f 100644 --- a/src/core/Piano.cpp +++ b/src/core/Piano.cpp @@ -70,19 +70,6 @@ Piano::Piano( InstrumentTrack* track ) : } - - - -/*! \brief Destroy this new keyboard display - * - */ -Piano::~Piano() -{ -} - - - - /*! \brief Turn a key on or off * * \param key the key number to change diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 973e5c817..0597cf2f5 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -50,16 +50,6 @@ AutomatableModelView::AutomatableModelView( ::Model* model, QWidget* _this ) : widget()->setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); } - - - -AutomatableModelView::~AutomatableModelView() -{ -} - - - - void AutomatableModelView::addDefaultActions( QMenu* menu ) { AutomatableModel* model = modelUntyped(); diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 4a0d22888..91804d136 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -112,16 +112,6 @@ FileBrowser::FileBrowser(const QString & directories, const QString & filter, show(); } - - - -FileBrowser::~FileBrowser() -{ -} - - - - bool FileBrowser::filterItems( const QString & filter, QTreeWidgetItem * item ) { // call with item=NULL to filter the entire tree @@ -338,16 +328,6 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) : } - - - -FileBrowserTreeWidget::~FileBrowserTreeWidget() -{ -} - - - - void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) { FileItem * f = dynamic_cast( itemAt( e->pos() ) ); diff --git a/src/gui/PianoView.cpp b/src/gui/PianoView.cpp index 2a64e72dd..6e8464dd4 100644 --- a/src/gui/PianoView.cpp +++ b/src/gui/PianoView.cpp @@ -130,19 +130,6 @@ PianoView::PianoView( QWidget * _parent ) : } - - - -/*! \brief Destroy this piano display view - * - */ -PianoView::~PianoView() -{ -} - - - - /*! \brief Map a keyboard key being pressed to a note in our keyboard view * * \param _k The keyboard scan code of the key being pressed. diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index b634ba819..4317066ab 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -133,12 +133,6 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma init(model, name); } - -Fader::~Fader() -{ -} - - void Fader::init(FloatModel * model, QString const & name) { setWindowTitle( name ); diff --git a/src/gui/widgets/Graph.cpp b/src/gui/widgets/Graph.cpp index 2cca2c424..ed57dcea6 100644 --- a/src/gui/widgets/Graph.cpp +++ b/src/gui/widgets/Graph.cpp @@ -56,13 +56,6 @@ Graph::Graph( QWidget * _parent, graphStyle _style, int _width, this, SLOT( updateGraph( ) ) ); } - -Graph::~Graph() -{ -} - - - void Graph::setForeground( const QPixmap &_pixmap ) { m_foreground = _pixmap; @@ -470,14 +463,6 @@ graphModel::graphModel( float _min, float _max, int _length, { } - - -graphModel::~graphModel() -{ -} - - - void graphModel::setRange( float _min, float _max ) { if( _min != m_minValue || _max != m_maxValue ) diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index 2dff70450..325c0171d 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -58,14 +58,6 @@ LcdSpinBox::LcdSpinBox( int numDigits, const QString& style, QWidget* parent, co { } - - -LcdSpinBox::~LcdSpinBox() -{ -} - - - void LcdSpinBox::update() { setValue( model()->value() + m_displayOffset ); diff --git a/src/gui/widgets/SideBar.cpp b/src/gui/widgets/SideBar.cpp index 2e6c2f048..01ea58919 100644 --- a/src/gui/widgets/SideBar.cpp +++ b/src/gui/widgets/SideBar.cpp @@ -41,9 +41,8 @@ public: m_orientation( _orientation ) { } - virtual ~SideBarButton() - { - } + + virtual ~SideBarButton() = default; Qt::Orientation orientation() const { diff --git a/src/gui/widgets/TabBar.cpp b/src/gui/widgets/TabBar.cpp index 115786be5..d40b41d98 100644 --- a/src/gui/widgets/TabBar.cpp +++ b/src/gui/widgets/TabBar.cpp @@ -41,16 +41,6 @@ TabBar::TabBar( QWidget * _parent, QBoxLayout::Direction _dir ) : setLayout( m_layout ); } - - - -TabBar::~TabBar() -{ -} - - - - TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id, bool _add_stretch, bool _text_is_tooltip ) { diff --git a/src/gui/widgets/TabWidget.cpp b/src/gui/widgets/TabWidget.cpp index 6fde217c1..f06710098 100644 --- a/src/gui/widgets/TabWidget.cpp +++ b/src/gui/widgets/TabWidget.cpp @@ -61,12 +61,6 @@ TabWidget::TabWidget( const QString & caption, QWidget * parent, bool usePixmap } - -TabWidget::~TabWidget() -{ -} - - void TabWidget::addTab( QWidget * w, const QString & name, const char *pixmap, int idx ) { setFont( pointSize<8>( font() ) ); diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index 2805aa8f4..2ef764c34 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -58,17 +58,6 @@ TimeDisplayWidget::TimeDisplayWidget() : this, SLOT( updateTime() ) ); } - - - -TimeDisplayWidget::~TimeDisplayWidget() -{ -} - - - - - void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) { m_displayMode = displayMode; diff --git a/src/gui/widgets/ToolButton.cpp b/src/gui/widgets/ToolButton.cpp index 2f89d8180..21363f66b 100644 --- a/src/gui/widgets/ToolButton.cpp +++ b/src/gui/widgets/ToolButton.cpp @@ -41,10 +41,3 @@ ToolButton::ToolButton( const QPixmap & _pixmap, const QString & _tooltip, ToolTip::add( this, _tooltip ); setIcon( _pixmap ); } - - - - -ToolButton::~ToolButton() -{ -} diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index 77693ace6..11c919f0e 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -40,16 +40,6 @@ AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : setName( tr( "Automation track" ) ); } - - - -AutomationTrack::~AutomationTrack() -{ -} - - - - bool AutomationTrack::play( const MidiTime & time_start, const fpp_t _frames, const f_cnt_t _frame_base, int _tco_num ) { @@ -108,16 +98,6 @@ AutomationTrackView::AutomationTrackView( AutomationTrack * _at, TrackContainerV setModel( _at ); } - - - -AutomationTrackView::~AutomationTrackView() -{ -} - - - - void AutomationTrackView::dragEnterEvent( QDragEnterEvent * _dee ) { StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 841050cc9..c37c1466f 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.cpp @@ -61,16 +61,6 @@ BBTCO::BBTCO( Track * _track ) : setAutoResize( false ); } - - - -BBTCO::~BBTCO() -{ -} - - - - void BBTCO::saveSettings( QDomDocument & doc, QDomElement & element ) { element.setAttribute( "name", name() ); @@ -168,16 +158,6 @@ BBTCOView::BBTCOView( TrackContentObject * _tco, TrackView * _tv ) : setStyle( QApplication::style() ); } - - - -BBTCOView::~BBTCOView() -{ -} - - - - void BBTCOView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "bb_track" ), diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 560cd73f7..8218d16f6 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -616,19 +616,6 @@ PatternView::PatternView( Pattern* pattern, TrackView* parent ) : setStyle( QApplication::style() ); } - - - - - -PatternView::~PatternView() -{ -} - - - - - void PatternView::update() { ToolTip::add(this, m_pat->name()); diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 28cda3ffd..7fda6512e 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -302,16 +302,6 @@ SampleTCOView::SampleTCOView( SampleTCO * _tco, TrackView * _tv ) : setStyle( QApplication::style() ); } - - - -SampleTCOView::~SampleTCOView() -{ -} - - - - void SampleTCOView::updateSample() { update();