浏览代码

Eliminate a few uses of NULL, and mention preference to not use it in the code convention. Ensure UIElementLoadChildXML returns a value.

Lasse Öörni 9 年之前
父节点
当前提交
fff10e15cf

+ 2 - 0
Docs/Reference.dox

@@ -3461,6 +3461,8 @@ byte[]     Bytecode, produced by AngelScript serializer
 
 - Pointers and references append the * or & symbol to the type without a space in between. For example Drawable* drawable, %Serializer& dest.
 
+- The macro NULL should not be used, 0 is used instead.
+
 - Class definitions proceed in the following order:
   - public constructors and the destructor
   - public virtual functions

+ 4 - 2
Source/Urho3D/AngelScript/APITemplates.h

@@ -952,12 +952,14 @@ static bool UIElementLoadXML(XMLFile* file, XMLFile* styleFile, UIElement* ptr)
 
 static UIElement* UIElementLoadChildXML(XMLFile* file, XMLFile* styleFile, UIElement* ptr)
 {
-    if (file == NULL)
-        return NULL;
+    if (!file)
+        return 0;
 
     XMLElement rootElem = file->GetRoot("element");
     if (rootElem)
         return ptr->LoadChildXML(rootElem, styleFile);
+    else
+        return 0;
 }
 
 static bool UIElementSaveXML(File* file, const String& indentation, UIElement* ptr)

+ 1 - 1
Source/Urho3D/UI/FontFaceFreeType.cpp

@@ -214,7 +214,7 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
         // are 29354 glyphs in msyh.ttf
         FT_ULong tagKern = FT_MAKE_TAG('k', 'e', 'r', 'n');
         FT_ULong kerningTableSize = 0;
-        FT_Error error = FT_Load_Sfnt_Table(face, tagKern, 0, NULL, &kerningTableSize);
+        FT_Error error = FT_Load_Sfnt_Table(face, tagKern, 0, 0, &kerningTableSize);
         if (error)
         {
             URHO3D_LOGERROR("Could not get kerning table length");

+ 4 - 4
Source/Urho3D/UI/UI.cpp

@@ -1171,7 +1171,7 @@ void UI::ProcessClickBegin(const IntVector2& cursorPos, int button, int buttons,
 
             // Handle click
             element->OnClickBegin(element->ScreenToElement(cursorPos), cursorPos, button, buttons, qualifiers, cursor);
-            SendClickEvent(E_UIMOUSECLICK, NULL, element, cursorPos, button, buttons, qualifiers);
+            SendClickEvent(E_UIMOUSECLICK, 0, element, cursorPos, button, buttons, qualifiers);
 
             // Fire double click event if element matches and is in time
             if (doubleClickElement_ && element == doubleClickElement_ &&
@@ -1179,7 +1179,7 @@ void UI::ProcessClickBegin(const IntVector2& cursorPos, int button, int buttons,
             {
                 element->OnDoubleClick(element->ScreenToElement(cursorPos), cursorPos, button, buttons, qualifiers, cursor);
                 doubleClickElement_.Reset();
-                SendClickEvent(E_UIMOUSEDOUBLECLICK, NULL, element, cursorPos, button, buttons, qualifiers);
+                SendClickEvent(E_UIMOUSEDOUBLECLICK, 0, element, cursorPos, button, buttons, qualifiers);
             }
             else
             {
@@ -1217,10 +1217,10 @@ void UI::ProcessClickBegin(const IntVector2& cursorPos, int button, int buttons,
             // If clicked over no element, or a disabled element, lose focus (but not if there is a modal element)
             if (!HasModalElement())
                 SetFocusElement(0);
-            SendClickEvent(E_UIMOUSECLICK, NULL, element, cursorPos, button, buttons, qualifiers);
+            SendClickEvent(E_UIMOUSECLICK, 0, element, cursorPos, button, buttons, qualifiers);
 
             if (clickTimer_.GetMSec(true) < (unsigned)(doubleClickInterval_ * 1000) && lastMouseButtons_ == buttons)
-                SendClickEvent(E_UIMOUSEDOUBLECLICK, NULL, element, cursorPos, button, buttons, qualifiers);
+                SendClickEvent(E_UIMOUSEDOUBLECLICK, 0, element, cursorPos, button, buttons, qualifiers);
         }
 
         lastMouseButtons_ = buttons;

+ 2 - 2
Source/Urho3D/UI/UIElement.cpp

@@ -310,7 +310,7 @@ UIElement* UIElement::LoadChildXML(const XMLElement& childElem, XMLFile* styleFi
     if (internalElem)
     {
         URHO3D_LOGERROR("Loading internal child element is not supported");
-        return NULL;
+        return 0;
     }
 
     String typeName = childElem.GetAttribute("type");
@@ -326,7 +326,7 @@ UIElement* UIElement::LoadChildXML(const XMLElement& childElem, XMLFile* styleFi
         if (!child->LoadXML(childElem, styleFile, setInstanceDefault))
         {
             RemoveChild(child, index);
-            return NULL;
+            return 0;
         }
     }
 

+ 1 - 1
Source/Urho3D/UI/UIElement.h

@@ -129,7 +129,7 @@ public:
     virtual bool LoadXML(const XMLElement& source, bool setInstanceDefault = false);
     /// Load from XML data with style. Return true if successful.
     virtual bool LoadXML(const XMLElement& source, XMLFile* styleFile, bool setInstanceDefault = false);
-    /// Create a child by loading from XML data with style. Returns the child element if successful, NULL if otherwise.
+    /// Create a child by loading from XML data with style. Returns the child element if successful, null if otherwise.
     virtual UIElement* LoadChildXML(const XMLElement& childElem, XMLFile* styleFile = 0, bool setInstanceDefault = false);
     /// Save as XML data. Return true if successful.
     virtual bool SaveXML(XMLElement& dest) const;