Ver Mensaje Individual
  #1  
Antiguo 03-03-2012
Gattaca Gattaca is offline
Miembro
 
Registrado: feb 2009
Posts: 31
Reputación: 0
Gattaca Va por buen camino
Angry Increíble error el Delphi va muy rapido!

Hola!

Tengo un increíble problema!!

Veran estoy leyendo un archivo binario a una velocidad creo que muy rapida, causandome el error "EAccessViolation", y la unica forma de solventarlo es agregando un "sleep(1)", haciendo que mi applicación valla más lenta!.

Esté es el loop principal llamado desde un menu para cargar el archivo.
La aplicación no dejo de darme errores, hasta que agregue el sleep antes de llamar a ReadItem()
Código Delphi [-]
      // Objects, walls, grounds, etc...
      for itemId := 100 to ItemCount - 100 do
      begin
        // con esta linea no me da error y carga más de 30000+ objetos del archivo binario
        // sin ella, me dá error!
        sleep(1);
        application.ProcessMessages;
        SetItem(itemId-100, ReadItem(itemId));
        //writeln(flogfile, 'Successfully readed Item #' + inttostr(itemId) + '.');

      end;

MI funcion ReadItem
Código Delphi [-]
function TDatFile.ReadItem(Id: UInt16): TItem;
var value: byte;
    return: TItem;
    spriteId: UInt16;
begin
  try
    while (value <> $FF) do
    begin

      value := ReadData.ReadByte();

      case value of
        $00:
          ReadData.ReadUInt16();
        $17, $20, $FF, $01, $02, $03, $04, $05, $06, $07, $08,
        $0B, $0C, $0D, $0E, $0F, $10, $11, $12,
        $13, $14, $15, $18, $1B, $1F, $1C
        : begin end;
        $09, $0A: begin ReadData.ReadUInt16(); end;
        $1A, $1D: begin ReadData.ReadUInt16(); end;
        $16, $19: begin ReadData.ReadUInt16(); ReadData.ReadUInt16(); end;
        $1E: begin ReadData.ReadUInt16(); end;
        else begin
          writeln(Flogfile, '   ERROR: Invalid Integer: ' + inttostr(value) + ' at item #' + inttostr(Id));
        end;
      end;

    end; // End flags

    return := TItem.Create;

    return.ID := Id;

    return.Width := ReadData.ReadByte();
    return.Height := ReadData.ReadByte();

    if (return.Width > 1) or (return.Height > 1) then
      return.CropImage := ReadData.ReadByte();

    return.Blendframes := ReadData.ReadByte();
    return.xRepeat := ReadData.ReadByte();
    return.yRepeat := ReadData.ReadByte();
    return.zRepeat := ReadData.ReadByte();
    return.Animations := ReadData.ReadByte();

    setLength(return.Sprites, return.SpritesCount);

    try
      for spriteId := 0 to return.SpritesCount - 1 do
      begin
        return.Sprites[spriteId] := ReadData.ReadUInt16();

        //writeln(flogfile, ' Readed Sprite #' + inttostr(return.Sprites[spriteid]));
      end;
    except
       on E : Exception do
      writeln(flogfile, ' CRITICAL ERROR AT OBJECT #' + inttostr(id) + ': '#13 + E.ClassName+' error raised, with message : '+E.Message);
    end;

  finally
    result := return;
  end;
  {except
    on E : Exception do
      writeln(flogfile, ' CRITICAL ERROR: '#13 + E.ClassName+' error raised, with message : '+E.Message);
  end; }
end;

Porfavor ayudenme, no tengo idea de que está mal en mi codigo para que me tire ese error!!

Usando Embarcadero Delphi XE2
Windows 7 x64 Home Premium
Tengo derechos de admin.
Responder Con Cita