ide/sdk: Fixed forcing bit depth option not invoked for static libraries
[sdk] / eda / libeda / src / idList.ec
index 1b08aeb..9da121d 100644 (file)
@@ -174,7 +174,14 @@ public class Id : uint
          // FIXME
          Table tbl = *class_data(table);
          Field idField = tbl.FindField(defaultIdField);
-         Row r { tbl };
+         Row r;
+         idRowCacheMutex.Wait();
+         if(!tbl.cachedIdRow)
+         {
+            tbl.cachedIdRow = Row { tbl };
+            incref tbl.cachedIdRow;
+         }
+         r = tbl.cachedIdRow;
 
          if(this)
          {
@@ -182,38 +189,47 @@ public class Id : uint
             {
                String name = null;
                Field * nameField = class_data(nameField);
-               char * fn = nameField->name;
+               if(nameField)
+               {
+#ifdef _DEBUG
+                  char * fn = nameField->name;
+#endif
+                  // Get name data from row
+                  int64 data = 0;
+                  Class type = nameField->type;
+                  if(type.type == unitClass && !type.typeSize)
+                  {
+                     Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
+                     if(dataType)
+                        type = dataType;
+                  }
+                  if(type.type == structClass)
+                     data = (int64)new0 byte[type.structSize];
+                  ((bool (*)())(void *)r.GetData)(r, *nameField, type, (type.type == structClass) ? (void *)data : &data);
 
-               // r.GetData(*nameField, name);
+                  if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
+                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)&data, tempString, null, null);
+                  else
+                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)data, tempString, null, null);
 
-               // Get name data from row
-               int64 data = 0;
-               Class type = nameField->type;
-               if(type.type == unitClass && !type.typeSize)
-               {
-                  Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
-                  if(dataType)
-                     type = dataType;
+                  strcpy(tempString, name ? name : "");
+                  if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
+                     type._vTbl[__ecereVMethodID_class_OnFree](type, data);
                }
-               if(type.type == structClass)
-                  data = (int64)new0 byte[type.structSize];
-               ((bool (*)())(void *)r.GetData)(r, *nameField, type, (type.type == structClass) ? (void *)data : &data);
-
-               if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
-                  name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)&data, tempString, null, null);
                else
-                  name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)data, tempString, null, null);
-
-               strcpy(tempString, name ? name : "");
-               if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                  type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+               {
+                  PrintLn("Id::OnGetString -- data type"/*, this._class.name, */" has no class_data(nameField)");
+               }
             }
+            else
+               sprintf(tempString, "(Invalid %s entry: %d)", tbl.name, this);
          }
          else
          {
             sprintf(tempString, $"(Click to add a new %s...)", $"item"/*class_data(addText)*/);
          }
-         delete r;
+         // delete r;
+         idRowCacheMutex.Release();
       }
       return tempString;
    }
@@ -320,11 +336,12 @@ public:
          channel.Serialize(none);
       }
    }
-
+   /*
    void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
    {
 
    }
+   */
    
    char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
    {
@@ -359,7 +376,10 @@ public:
 
    int OnCompare(IdList b)
    {
-      if(count > b.count) return 1;
+      if(!this && !b) return 0;
+      else if(this && !b) return 1;
+      else if(!this && b) return -1;
+      else if(count > b.count) return 1;
       else if(count < b.count) return -1;
       else
       {
@@ -480,7 +500,7 @@ public class StringList
 
    bool Add(String string)
    {
-      BTNode node { key = (uint)CopyString(string) };
+      BTNode node { key = (uintptr)CopyString(string) };
       if(strings.Add(node))
          return true;
       else