瀏覽代碼

Minor changes.

Eugene Kozlov 8 年之前
父節點
當前提交
8fd843703e
共有 3 個文件被更改,包括 12 次插入9 次删除
  1. 2 0
      Source/Urho3D/Core/Object.cpp
  2. 8 5
      Source/Urho3D/Resource/Image.cpp
  3. 2 4
      Source/Urho3D/Scene/Serializable.cpp

+ 2 - 0
Source/Urho3D/Core/Object.cpp

@@ -88,6 +88,7 @@ void Object::OnEvent(Object* sender, StringHash eventType, VariantMap& eventData
 {
 {
     if (blockEvents_)
     if (blockEvents_)
         return;
         return;
+
     // Make a copy of the context pointer in case the object is destroyed during event handler invocation
     // Make a copy of the context pointer in case the object is destroyed during event handler invocation
     Context* context = context_;
     Context* context = context_;
     EventHandler* specific = nullptr;
     EventHandler* specific = nullptr;
@@ -304,6 +305,7 @@ void Object::SendEvent(StringHash eventType, VariantMap& eventData)
 
 
     if (blockEvents_)
     if (blockEvents_)
         return;
         return;
+
     // Make a weak pointer to self to check for destruction during event handling
     // Make a weak pointer to self to check for destruction during event handling
     WeakPtr<Object> self(this);
     WeakPtr<Object> self(this);
     Context* context = context_;
     Context* context = context_;

+ 8 - 5
Source/Urho3D/Resource/Image.cpp

@@ -2326,7 +2326,13 @@ bool Image::SetSubimage(const Image* image, const IntRect& rect)
 
 
     if (depth_ > 1 || IsCompressed())
     if (depth_ > 1 || IsCompressed())
     {
     {
-        URHO3D_LOGERROR("SetSubimage not supported for Compressed or 3D images");
+        URHO3D_LOGERROR("Image::SetSubimage is not supported for compressed or 3D images");
+        return false;
+    }
+
+    if (components_ != image->components_)
+    {
+        URHO3D_LOGERROR("Can not set subimage in image " + GetName() + " with different number of components");
         return false;
         return false;
     }
     }
 
 
@@ -2340,14 +2346,11 @@ bool Image::SetSubimage(const Image* image, const IntRect& rect)
     const int destHeight = rect.Height();
     const int destHeight = rect.Height();
     if (destWidth == image->GetWidth() && destHeight == image->GetHeight())
     if (destWidth == image->GetWidth() && destHeight == image->GetHeight())
     {
     {
-        // \todo Revise this place
-        const int components = Min((int)components_, (int)image->components_);
-
         unsigned char* src = image->GetData();
         unsigned char* src = image->GetData();
         unsigned char* dest = data_.Get() + (rect.top_ * width_ + rect.left_) * components_;
         unsigned char* dest = data_.Get() + (rect.top_ * width_ + rect.left_) * components_;
         for (int i = 0; i < destHeight; ++i)
         for (int i = 0; i < destHeight; ++i)
         {
         {
-            memcpy(dest, src, destWidth * components);
+            memcpy(dest, src, destWidth * components_);
 
 
             src += destWidth * image->components_;
             src += destWidth * image->components_;
             dest += width_ * components_;
             dest += width_ * components_;

+ 2 - 4
Source/Urho3D/Scene/Serializable.cpp

@@ -87,8 +87,7 @@ void Serializable::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
         break;
         break;
 
 
     case VAR_INT64:
     case VAR_INT64:
-        // \todo Revise this place
-        *(reinterpret_cast<unsigned long long*>(dest)) = src.GetUInt64();
+        *(reinterpret_cast<long long*>(dest)) = src.GetInt64();
         break;
         break;
 
 
     case VAR_BOOL:
     case VAR_BOOL:
@@ -197,8 +196,7 @@ void Serializable::OnGetAttribute(const AttributeInfo& attr, Variant& dest) cons
         break;
         break;
 
 
     case VAR_INT64:
     case VAR_INT64:
-        // \todo Revise this place
-        dest = *(reinterpret_cast<const unsigned long long*>(src));
+        dest = *(reinterpret_cast<const long long*>(src));
         break;
         break;
 
 
     case VAR_BOOL:
     case VAR_BOOL: