Browse Source

add extra checks

add extra checks around an empty stringtableentry for assets and bitmap controls
marauder2k7 2 tháng trước cách đây
mục cha
commit
08f52cfa16

+ 4 - 4
Engine/source/T3D/assets/ImageAsset.h

@@ -243,7 +243,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File() == _in)                                                                                                                                            \
          return;                                                                                                                                                              \
-      if(_in == NULL || _in == StringTable->EmptyString())                                                                                                                    \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset = NULL;                                                                                                                                               \
          m##name##File = "";                                                                                                                                                  \
@@ -300,7 +300,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File() == _in)                                                                                                                                            \
          return;                                                                                                                                                              \
-      if(_in == NULL || _in == StringTable->EmptyString())                                                                                                                    \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset = NULL;                                                                                                                                               \
          m##name##File = "";                                                                                                                                                  \
@@ -364,7 +364,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File(index) == _in)                                                                                                                                       \
          return;                                                                                                                                                              \
-      if(_in == NULL || _in == StringTable->EmptyString())                                                                                                                    \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset[index] = NULL;                                                                                                                                        \
          m##name##File[index] = "";                                                                                                                                           \
@@ -422,7 +422,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File(index) == _in)                                                                                                                                       \
          return;                                                                                                                                                              \
-      if(_in == NULL || _in == StringTable->EmptyString())                                                                                                                    \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset[index] = NULL;                                                                                                                                        \
          m##name##File[index] = "";                                                                                                                                           \

+ 3 - 3
Engine/source/T3D/assets/ShapeAsset.h

@@ -513,7 +513,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File() == _in)                                                                                                                                            \
          return;                                                                                                                                                              \
-      if (_in == NULL || _in == StringTable->EmptyString())                                                                                                                   \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset = NULL;                                                                                                                                               \
          m##name##File = "";                                                                                                                                                  \
@@ -569,7 +569,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File() == _in)                                                                                                                                            \
          return;                                                                                                                                                              \
-      if (_in == NULL || _in == StringTable->EmptyString())                                                                                                                   \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset = NULL;                                                                                                                                               \
          m##name##File = "";                                                                                                                                                  \
@@ -632,7 +632,7 @@ public:
          return;                                                                                                                                                              \
       if(get##name##File(index) == _in)                                                                                                                                       \
          return;                                                                                                                                                              \
-      if (_in == NULL || _in == StringTable->EmptyString())                                                                                                                   \
+      if(_in == NULL || _in == StringTable->EmptyString() || _in == "")                                                                                                       \
       {                                                                                                                                                                       \
          m##name##Asset[index] = NULL;                                                                                                                                        \
          m##name##File[index] = "";                                                                                                                                           \

+ 6 - 0
Engine/source/gui/buttons/guiBitmapButtonCtrl.h

@@ -123,6 +123,12 @@ private:
    String               mBitmapFile; 
 public:
    void _setBitmap(StringTableEntry _in) {
+      if (_in == NULL || _in == StringTable->EmptyString() || _in == "")
+      {
+         mBitmapAsset = NULL;
+         mBitmapFile = "";
+         return;
+      }
    if (mBitmapAsset.getAssetId() == _in) return; if (!AssetDatabase.isDeclaredAsset(_in)) {
       StringTableEntry imageAssetId = ImageAsset::smNoImageAssetFallback; AssetQuery query; S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, _in); if (foundAssetcount != 0) {
          imageAssetId = query.mAssetList[0];

+ 10 - 7
Engine/source/gui/controls/guiBitmapCtrl.cpp

@@ -121,16 +121,19 @@ void GuiBitmapCtrl::setBitmap(const char* name, bool resize)
       if (assetId != StringTable->EmptyString())
          _setBitmap(assetId);
       else
-         _setBitmap(name);
+         _setBitmap(StringTable->EmptyString());
    }
 
-   mBitmap = mBitmapAsset->getTexture(&GFXDefaultGUIProfile);
-
-   if (getBitmap() && resize)
+   if (mBitmapAsset.notNull())
    {
-     
-      setExtent(mBitmap->getWidth(), mBitmap->getHeight());
-      updateSizing();
+      mBitmap = mBitmapAsset->getTexture(&GFXDefaultGUIProfile);
+
+      if (getBitmap() && resize)
+      {
+
+         setExtent(mBitmap->getWidth(), mBitmap->getHeight());
+         updateSizing();
+      }
    }
 
    setUpdate();