Minor clean-ups (redundant 'virtuals')


#1

hi jules,


here are a few redundant 'virtuals' if you want to clean them up (?)

in juce_AAX_Wrapper.cpp :
virtual AAX_Result GetViewSize (AAX_Point* viewSize) const override


in juce_TopLevelWindow.h :
virtual void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = nullptr) override;


in juce_Component.h :

virtual void mouseMove (const MouseEvent& event) override;
virtual void mouseEnter (const MouseEvent& event) override;
virtual void mouseExit (const MouseEvent& event) override;
virtual void mouseDown (const MouseEvent& event) override;
virtual void mouseDrag (const MouseEvent& event) override;
virtual void mouseUp (const MouseEvent& event) override;
virtual void mouseDoubleClick (const MouseEvent& event) override;
virtual void mouseWheelMove (const MouseEvent& event,
                                 const MouseWheelDetails& wheel) override;


#2

Thanks! Do you have a tool that finds these, or did you just spot them manually?


#3

(BTW the ones in Component are done like that deliberately, so that when people browse the code, it's obvious that they can overload those methods)


#4

Do you have a tool that finds these

I just searched for the regular expression : (virtual (.*) override)

(but it does not find the ones that are broken other multiple lines such as Component::mouseWheelMove)

 


#5

I also noticed some other redundant virtuals - on destructors for these classes:

  • Component
  • Button
  • Typeface
  • DeviceChangeDetector (juce_win32_HiddenMessageWindow.h)
  • MessageManager::MessageBase
  • ComBaseClassHelperBase (juce_win32_ComSmartPtr.h)
  • Drawable
  • MenuBarModel
  • FileBasedDocument

#6

Why are those redundant? according to this http://stackoverflow.com/questions/461203/when-to-use-virtual-destructors

I would have thought they were necessary


#7

Fair point. Looking at this list, I think they were all classes that started off as base classes and then were later changed to derive from something else, at which point I forgot to remove the superfluous virtuals.


#8

It's only necessary in the base class. In any class that derives from another virtual class, the destructor automatically has to be virtual, so there's no need to exlpicitly give it the keyword.