ecere/gui/EditBox: Fixed hanging caused by 308c3f8a022f58c179f5d52f87be2609fba4ddd8
[sdk] / ecere / src / com / instance.ec
index 5b9e157..21e0c55 100644 (file)
@@ -2591,6 +2591,8 @@ public dllexport Class eSystem_RegisterClass(ClassType type, char * name, char *
             if(strstr(name, "ecere::sys::EARHeader") ||
                strstr(name, "AnchorValue") ||
                !strcmp(name, "ecere::com::CustomAVLTree") ||
+               !strcmp(name, "ecere::com::Array") ||
+               !strcmp(name, "ecere::gui::Window") ||
                !strcmp(name, "ecere::sys::Mutex"));   // Never recompute these, they're always problematic (errors, crashes)
             else
             {
@@ -4349,21 +4351,18 @@ public dllexport void * eInstance_New(Class _class)
 #endif
       {
          int size = _class.structSize;
-         Module module = _class.module;
-         Application application = module ? module.application : null;
-         int flags = application ? application.isGUIApp : 0;
+         int flags = _class.module.application.isGUIApp;
          bool inCompiler = (flags & 8) ? true : false;
-         if(inCompiler)
-         {
-            bool force32Bits = (flags & 4) ? true : false;
-            if(force32Bits)
-            {
-               // Allocate 64 bit sizes for these when cross-compiling for 32 bit to allow loaded libraries to work properly
-               if(!strcmp(_class.name, "Module"))
-                  size = 560;
-               else if(_class.templateClass && !strcmp(_class.templateClass.name, "Map"))
-                  size = 40;
-            }
+         bool force32Bits = (flags & 4) ? true : false;
+         if(force32Bits && inCompiler)
+         {
+            // Allocate 64 bit sizes for these when cross-compiling for 32 bit to allow loaded libraries to work properly
+            if(!strcmp(_class.name, "Module"))
+               size = 560;
+            else if(_class.templateClass && !strcmp(_class.templateClass.name, "Map"))
+               size = 40;
+            else
+               size *= 3;
          }
          instance = _calloc(1, size);
       }
@@ -5188,6 +5187,7 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
          module.name = CopyString(name);
          module.Unload = Unload;
          module.origImportType = normalImport;
+
          if(!Load(module))
          {
             eInstance_Delete((Instance)module);
@@ -5218,11 +5218,13 @@ static Module Module_Load(Module fromModule, char * name, AccessMode importAcces
             module.library = null;
             module.name = CopyString(name);
             module.Unload = Unload;
+
             if(!Load(module))
             {
                eInstance_Delete((Instance)module);
                module = null;
             }
+
             fromModule.application.allModules.Add(module);
          }
          if(module)
@@ -5764,13 +5766,21 @@ public dllexport void eInstance_FireWatchers(Instance instance, Property _proper
 {
    if(instance && _property && _property.isWatchable)
    {
-      OldList * watchers = (OldList *)((byte *)instance + _property.watcherOffset);
-      Watcher watcher, next;
-
-      for(watcher = watchers->first; watcher; watcher = next)
+      Module module = instance._class ? instance._class.module : null;
+      Application application = module ? module.application : null;
+      int flags = application ? application.isGUIApp : 0;
+      bool inCompiler = (flags & 8) ? true : false;
+      bool force32Bits = (flags & 4) ? true : false;
+      if(!force32Bits || !inCompiler)
       {
-         next = watcher.next;
-         watcher.callback(watcher.object, instance);
+         OldList * watchers = (OldList *)((byte *)instance + _property.watcherOffset);
+         Watcher watcher, next;
+
+         for(watcher = watchers->first; watcher; watcher = next)
+         {
+            next = watcher.next;
+            watcher.callback(watcher.object, instance);
+         }
       }
    }
 }
@@ -6625,13 +6635,14 @@ public int UTF16toUTF8Buffer(uint16 * source, byte * dest, int max)
    return d;
 }
 
+// NOTE: UTF8GetChar now returns 0 into numBytes for the null-terminating character ('\0')
 public unichar UTF8GetChar(char * string, int * numBytes)
 {
    unichar ch;
    byte b = ((byte *)string)[0];
    int i;
    byte mask = 0x7F;
-   int nb = 1;
+   int nb = b ? 1 : 0;
    ch = 0;
    if(b & 0x80)
    {