Patch to handle serialization of nested 'normal' classes
authorJerome St-Louis <jerome@ecere.com>
Thu, 23 Jun 2011 22:56:38 +0000 (18:56 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 23 Jun 2011 23:03:54 +0000 (19:03 -0400)
Fixed a missing return value
Tweaked EDA GUI code to act sensibly with a non-String 'name field'
Allowed overriding the name field in the GenericEditor's list

ecere/src/com/dataTypes.ec
eda/libeda/src/gui.ec
samples/db/MovieCollection/genericEditor.ec

index 1dd6a2d..433a0b7 100644 (file)
@@ -1005,9 +1005,9 @@ static void OnSerialize(Class _class, void * data, IOChannel channel)
                      }
                      else
                      {
-                        if(!strcmp(memberType.name, "String"))
+                        if(!strcmp(memberType.name, "String") || memberType.type == normalClass || memberType.type == noHeadClass)
                         {
-                           memberType._vTbl[__ecereVMethodID_class_OnSerialize](memberType, *(String *)((byte *)data + member._class.offset + member.offset), channel);
+                           memberType._vTbl[__ecereVMethodID_class_OnSerialize](memberType, *(void **)((byte *)data + member._class.offset + member.offset), channel);
                         }
                         else
                            memberType._vTbl[__ecereVMethodID_class_OnSerialize](memberType, ((byte *)data + (((member._class.type == normalClass) ? member._class.offset : 0) + member.offset)), channel);
index 35418d5..fc72410 100644 (file)
@@ -611,6 +611,7 @@ public class EditFieldDropDataBox : FieldDropDataBox
    {
       row.Add();
       row.SetData(dropBox.nameField, entry);
+      return true;
    }
 }
 
@@ -699,12 +700,16 @@ public class ListSection : Group
    {
       if(listSection.fldId && listSection.fldName)
       {
+         bool stringName = !strcmp(listSection.fldName.type.dataTypeString, "char *");
          while(r.Next())
          {
             Id id = 0;
             String s = null;
             r.GetData(listSection.fldId, id);
-            r.GetData(listSection.fldName, s);
+            if(stringName)
+               r.GetData(listSection.fldName, s);
+            else
+               s = PrintString("Entry ", id);
             listSection.list.AddString(s).tag = id;
             delete s;
          }
@@ -744,8 +749,10 @@ public class ListSection : Group
                      id = curID;
                   else
                      r.SetData(fldId, id);
-               }               
-               r.SetData(fldName, "[New]");
+               }
+               if(!strcmp(fldName.type.dataTypeString, "char *"))
+                  r.SetData(fldName, "[New]");
+
                if(fldActive)
                   r.SetData(fldActive, active);
 
@@ -992,6 +999,7 @@ public:
    
    void EditSave()
    {
+      bool stringName = !strcmp(list.fldName.type.dataTypeString, "char *");
       OldLink link;
       String name = null;
 
@@ -1004,7 +1012,10 @@ public:
       // ADDED THIS HERE FOR SQLITE TO REFRESH
       editRow.Find(list.fldId, middle, nil, list.list.currentRow.tag);
 
-      editRow.GetData(list.fldName, name);
+      if(stringName)
+         editRow.GetData(list.fldName, name);
+      else
+         name = PrintString("Entry ", list.list.currentRow.tag);
 
       NotifyEditSave(master, this, name);
       delete name;
index 94231ed..6e6a084 100644 (file)
@@ -30,7 +30,8 @@ class GenericEditor : Window
          Clear();
 
          editor.table = value;
-         list.fldName = value.FindField("Name");
+         if(!list.fldName)
+            list.fldName = value.FindField("Name");
          list.table = value;
          for(f = value.firstField; f; f = f.next)
          {