Browse Source

Fixed PLugin items not being removed on project unload.

Matt Benic 9 years ago
parent
commit
d15e5cb9e7

+ 2 - 2
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -56,10 +56,10 @@ class MainFrameMenu extends Atomic.ScriptObject {
 
     removePluginMenuItemSource(id: string) {
         if (this.pluginMenuItemSource) {
-            this.pluginMenuItemSource.removeItem(id);
+            this.pluginMenuItemSource.removeItemWithStr(id);
             if (0 == this.pluginMenuItemSource.itemCount) {
                 var developerMenuItemSource = MenuItemSources.getMenuItemSource("menu developer");
-                developerMenuItemSource.removeItem("Plugins");
+                developerMenuItemSource.removeItemWithStr("Plugins");
                 this.pluginMenuItemSource = null;
             }
         }

+ 12 - 1
Source/Atomic/UI/UISelectItem.cpp

@@ -84,7 +84,7 @@ UISelectItemSource::~UISelectItemSource()
 
 }
 
-void UISelectItemSource::RemoveItem(const String& id)
+void UISelectItemSource::RemoveItemWithId(const String& id)
 {
     tb::TBID test = TBID(id.CString());
     for (List<SharedPtr<UISelectItem> >::Iterator itr = items_.Begin(); itr != items_.End(); itr++)
@@ -96,6 +96,17 @@ void UISelectItemSource::RemoveItem(const String& id)
     }
 }
 
+void UISelectItemSource::RemoveItemWithStr(const String& str)
+{
+    for (List<SharedPtr<UISelectItem> >::Iterator itr = items_.Begin(); itr != items_.End(); itr++)
+    {
+        if ((*itr)->GetStr() == str) {
+            items_.Erase(itr);
+            break;
+        }
+    }
+}
+
 TBSelectItemSource *UISelectItemSource::GetTBItemSource()
 {
     // caller's responsibility to clean up

+ 3 - 1
Source/Atomic/UI/UISelectItem.h

@@ -44,6 +44,7 @@ public:
 
     void SetString(const String& str) { str_ = str; }
     void SetID(const String& id);
+    const String& GetStr() { return str_; }
     tb::TBID GetID() { return id_; }
     void SetSkinImage(const String& skinImage);
     void SetSubSource(UISelectItemSource *subSource);
@@ -73,7 +74,8 @@ public:
     virtual ~UISelectItemSource();
 
     void AddItem(UISelectItem* item) { items_.Push(SharedPtr<UISelectItem>(item)); }
-    void RemoveItem(const String& id);
+    void RemoveItemWithId(const String& id);
+    void RemoveItemWithStr(const String& str);
     int GetItemCount() { return items_.Size(); }
 
     void Clear() { items_.Clear(); }