From 0d750cdbaf28a21a4947de0335997c037e531d27 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 19 Nov 2013 16:57:23 -0800 Subject: [PATCH] Adds virtual destructors on Interfaces Classes with at least one virtual function needs a virtual destructor. This patch adds virtual destructors to Interface classes And also enables 'warn on missing virtual destructors' --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/CCLabelTextFormatProtocol.h | 48 ++++++++++--------- cocos/2d/CCProtocols.h | 13 ++++- cocos/2d/CCTextFieldTTF.h | 2 + cocos/2d/CCTransition.h | 2 + cocos/2d/platform/CCSAXParser.h | 2 + .../cocosbuilder/CCBAnimationManager.h | 1 + cocos/gui/UIScrollInterface.h | 3 ++ 8 files changed, 47 insertions(+), 26 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 692b7ad548..507d392456 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -1dbcea49018d245ac72bf4138633f3905ef4dc7f \ No newline at end of file +0d9ce76f7e63d75718c38b1137b2580e19d0db76 \ No newline at end of file diff --git a/cocos/2d/CCLabelTextFormatProtocol.h b/cocos/2d/CCLabelTextFormatProtocol.h index 8e1530fb3e..179849e033 100644 --- a/cocos/2d/CCLabelTextFormatProtocol.h +++ b/cocos/2d/CCLabelTextFormatProtocol.h @@ -42,36 +42,38 @@ struct LetterInfo class CC_DLL LabelTextFormatProtocol { public: - virtual bool recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) = 0; - virtual bool recordPlaceholderInfo(int spriteIndex) = 0; - virtual std::vector *getLettersInfo() = 0; - virtual float getLetterPosXLeft(int index) const = 0; - virtual float getLetterPosXRight(int index) const = 0; + + virtual ~LabelTextFormatProtocol() {} + + virtual bool recordLetterInfo(const cocos2d::Point& point,unsigned short int theChar, int spriteIndex) = 0; + virtual bool recordPlaceholderInfo(int spriteIndex) = 0; + virtual std::vector *getLettersInfo() = 0; + virtual float getLetterPosXLeft(int index) const = 0; + virtual float getLetterPosXRight(int index) const = 0; // sprite related stuff - virtual cocos2d::Sprite *getLetter(int ID) = 0; + virtual cocos2d::Sprite *getLetter(int ID) = 0; // font related stuff - virtual int getCommonLineHeight() const = 0; - virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const = 0; - virtual int getXOffsetForChar(unsigned short c) const = 0; - virtual int getYOffsetForChar(unsigned short c) const = 0; - virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const = 0; - virtual cocos2d::Rect getRectForChar(unsigned short c) const = 0; + virtual int getCommonLineHeight() const = 0; + virtual int getKerningForCharsPair(unsigned short first, unsigned short second) const = 0; + virtual int getXOffsetForChar(unsigned short c) const = 0; + virtual int getYOffsetForChar(unsigned short c) const = 0; + virtual int getAdvanceForChar(unsigned short c, int hintPositionInString) const = 0; + virtual cocos2d::Rect getRectForChar(unsigned short c) const = 0; // string related stuff - virtual int getStringNumLines() const = 0; - virtual int getStringLenght() const = 0; - virtual unsigned short getCharAtStringPosition(int position) const = 0; - virtual unsigned short * getUTF8String() const = 0; - virtual void assignNewUTF8String(unsigned short *newString) = 0; - virtual TextHAlignment getTextAlignment() const = 0; + virtual int getStringNumLines() const = 0; + virtual int getStringLenght() const = 0; + virtual unsigned short getCharAtStringPosition(int position) const = 0; + virtual unsigned short * getUTF8String() const = 0; + virtual void assignNewUTF8String(unsigned short *newString) = 0; + virtual TextHAlignment getTextAlignment() const = 0; // label related stuff - virtual float getMaxLineWidth() const = 0; - virtual bool breakLineWithoutSpace() const = 0; - virtual cocos2d::Size getLabelContentSize() const = 0; - virtual void setLabelContentSize(const Size &newSize) = 0; - + virtual float getMaxLineWidth() const = 0; + virtual bool breakLineWithoutSpace() const = 0; + virtual cocos2d::Size getLabelContentSize() const = 0; + virtual void setLabelContentSize(const Size &newSize) = 0; }; NS_CC_END diff --git a/cocos/2d/CCProtocols.h b/cocos/2d/CCProtocols.h index 993d1fa161..63296d7f03 100644 --- a/cocos/2d/CCProtocols.h +++ b/cocos/2d/CCProtocols.h @@ -38,7 +38,9 @@ NS_CC_BEGIN class CC_DLL RGBAProtocol { public: - /** + virtual ~RGBAProtocol() {} + + /** * Changes the color with R,G,B bytes * * @param color Example: Color3B(255,100,0) means R=255, G=100, B=0 @@ -165,6 +167,8 @@ public: class CC_DLL BlendProtocol { public: + virtual ~BlendProtocol() {} + /** * Sets the source blending function. * @@ -197,6 +201,7 @@ public: class CC_DLL TextureProtocol : public BlendProtocol { public: + virtual ~TextureProtocol() {} /** * Returns the currently used texture * @@ -222,6 +227,8 @@ public: class CC_DLL LabelProtocol { public: + virtual ~LabelProtocol() {} + /** * Sets a new label using a string * @@ -247,7 +254,9 @@ public: class CC_DLL DirectorDelegate { public: - /** + virtual ~DirectorDelegate() {} + + /** * Will be called by Director when the projection is updated, and "custom" projection is used * @js NA * @lua NA diff --git a/cocos/2d/CCTextFieldTTF.h b/cocos/2d/CCTextFieldTTF.h index a6ae42dc8e..d36df0c547 100644 --- a/cocos/2d/CCTextFieldTTF.h +++ b/cocos/2d/CCTextFieldTTF.h @@ -40,6 +40,8 @@ class TextFieldTTF; class CC_DLL TextFieldDelegate { public: + virtual ~TextFieldDelegate() {} + /** @brief If the sender doesn't want to attach to the IME, return true; */ diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index bdcd8b58e7..77e5845812 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -50,6 +50,8 @@ class Node; class CC_DLL TransitionEaseScene// : public Object { public: + virtual ~TransitionEaseScene() {} + /** returns the Ease action that will be performed on a linear action. @since v0.8.2 */ diff --git a/cocos/2d/platform/CCSAXParser.h b/cocos/2d/platform/CCSAXParser.h index 68b3ce1cef..452061776a 100644 --- a/cocos/2d/platform/CCSAXParser.h +++ b/cocos/2d/platform/CCSAXParser.h @@ -39,6 +39,8 @@ typedef unsigned char CC_XML_CHAR; class CC_DLL SAXDelegator { public: + virtual ~SAXDelegator() {} + /** * @js NA * @lua NA diff --git a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h index e9755bbfb1..4c4270ee04 100644 --- a/cocos/editor-support/cocosbuilder/CCBAnimationManager.h +++ b/cocos/editor-support/cocosbuilder/CCBAnimationManager.h @@ -13,6 +13,7 @@ namespace cocosbuilder { class CCBAnimationManagerDelegate { public: + virtual ~CCBAnimationManagerDelegate() {} virtual void completedAnimationSequenceNamed(const char *name) = 0; }; diff --git a/cocos/gui/UIScrollInterface.h b/cocos/gui/UIScrollInterface.h index dfff4cd66c..ace2f253b5 100644 --- a/cocos/gui/UIScrollInterface.h +++ b/cocos/gui/UIScrollInterface.h @@ -31,6 +31,9 @@ namespace gui { class UIScrollInterface { +public: + virtual ~UIScrollInterface() {} + protected: virtual void handlePressLogic(const cocos2d::Point &touchPoint) = 0; virtual void handleMoveLogic(const cocos2d::Point &touchPoint) = 0;