1

(1 replies, posted in Bug Solved)

To luckylazarus:
In my previous post I mention two bugs found in code version 0.32 and the first is still present in new version (0.33):

BUG CODE: //--> index is out of bounds
{ Storage Version }
   FStorageVersion := StorageInfoStrings[1];
   
FIXED CODE:
{ Storage Version } 
   FStorageVersion := StorageInfoStrings[0];


This message is prompting every time when I open database:
Msg1044 =   'TSqlitePassDatabase.DataTypeOptions.LoadFromDatabase: Error while loading data from database. '
          + 'The "SqlitePass__DbSettings" table is corrupted or was created using an old version of this component. '
          + ' Do you want to remove the "SqlitePass__DbSettings" from your database ? (A new table will be created on database closing).';

I will explain why smile :

in SqlPassDatabase.inc

procedure TSqlitePassDatabaseDataTypeOptions.LoadFromDatabase(_LoadOptions: TsqlitePassDataTypeStorageOptions = []);
...

{ Storage Version }
   FStorageVersion := StorageInfoStrings[1]; // THIS PRODUCES EXCEPTION EVERY TIME!!!!   
....
....
   except
      if MessageDlg(Msg1044, mtWarning, [mbYes, mbNo], 0) = mrYes
         then FDatabase.Engine.Exec('Drop table "SqlitePass__DbSettings";'); //AND HERE IS CAUGHT (HANDLED)
   end; {Try 2 }

So we get every time this annoying message although we already saved new "SqlitePass__DbSettings" in database,
plus further code after "exception producer" obviously has not been executed (nevertheless is critical or not).

2

(12 replies, posted in General)

I must correct myself because in new version (0.33) this is already changed.
I can report that if we add lines below to the SqlitePassDbo.inc is compilable for the Delphi 2006 (and I assume that this is valid for all versions between ver150 and ver180) compiler too  smile .

....

{$IFDEF WIN32}
  {$IFDEF VER180}
    {$DEFINE Delphi7}
    {$DEFINE Delphi6}
    {$DEFINE Delphi5}
    {$DEFINE Delphi4}
  {$ENDIF}

  {$IFDEF VER150}
    {$DEFINE Delphi7}
    {$DEFINE Delphi6}
    {$DEFINE Delphi5}
    {$DEFINE Delphi4}
  {$ENDIF}

....

3

(12 replies, posted in General)

SListIndexError is at least from Delphi 6 located in RTLConsts (so the same as Free Pascal).
So Chukkan quick and dirty solution for you is (at least for 0.32 version smile) that you do change only in one place in SqlPassUtils.pas:

unit SqlitePassUtils;
{$i SqlitePassDbo.inc}
interface

uses
{$IFDEF FPC}
RtlConsts,
{$ELSE}
    {$IFDEF VER150} //This is for Delphi 7
    RTLConsts,
    {$ELSE}
    Consts,
    {$ENDIF}
{$ENDIF}
{$IFDEF WIN32}
Windows,
{$ENDIF}
Classes, SysUtils, Db;

But in further I think this compiler directives (IFDEFs smile) should be arranged similar (or almost equal) as in jedi.inc (so that
anyone can use sqlitepass instantly) file of project JEDI (JCL, JVCL,...),
because Delphi 4 is rather old and not anyone use the Free Pascal (or Lazarus framework) as first choice Object Pascal language (as in my case smile).

I'm not really very experienced delphi programmer, but I encounter some problems on openning and closing the database.
I must mention that compiling is done in Turbo Delphi 2006 Pro (some $IFDEFs on uses...) with 0.32 version of sqlitepass.

I tried to fix those bugs (annoying messages or exceptions were gone, about "real" functionality of code related to Loading and Saving to database I don't know if it is all right):

About functionality as I see it:
Only functional part of "LoadFromDatabase" procedure is used in next procedure and as we see here is exploited only
LoadFromDatabase for SoCustomFieldDefs, where are others? Is this bug or yet not finished feature?

SqlitePassDatabaseParts.inc
procedure TSqlitePassTableDefs.Refresh;
...
{ Loads the DatatypeOptions if needed }
If Not (soManual in FDatabase.FDataTypeOptions.LoadOptions)
   and (SoCustomFieldDefs in FDatabase.FDataTypeOptions.LoadOptions)
   then FDatabase.FDatatypeOptions.LoadFromDatabase([SoCustomFieldDefs]);


BUGS "SOLVED" smile :
in SqlPassDatabase.inc

procedure TSqlitePassDatabaseDataTypeOptions.LoadFromDatabase(_LoadOptions: TsqlitePassDataTypeStorageOptions = []);
...
BUG CODE: //error --> index is out of bounds
{ Storage Version }
   FStorageVersion := StorageInfoStrings[1];
   

FIXED CODE:
{ Storage Version } 
   FStorageVersion := StorageInfoStrings[0];
...   

procedure TSqlitePassDatabaseDataTypeOptions.SaveToDatabase(_SaveOptions: TsqlitePassDataTypeStorageOptions = []);
...
BUG CODE:  //error --> RowId should not be forced to ftMemo
{ Enforces fields fieldTypes to ftMemo whatever Databasetype is used }
     For i := 0 to Pred(DbSettingTableDef.FieldDefs.Count)
         do DbSettingTableDef.FieldDefs[i].DataType := ftMemo;

This bug lead us to Access violation in next procedure:
procedure TSqlitePassMemRecord.ClearAndFree(FieldDefs: TFieldDefs = nil);
...
    if (FieldDefs[Idx].DataType in SqlitePassBlobFieldTypes)
        and (FieldsValues[Idx] <> '') then
          begin
          BlobStream := TMemoryStream(StrToInt(FieldsValues[Idx])); //HERE THE BUG ESCALATES TO ACCESS VIOLATION
          BlobStream.Free;
          end;
    end; { Assigned }

FIXED CODE: 
   { Enforces fields fieldTypes to ftMemo whatever Databasetype is used }
     For i := 0 to Pred(DbSettingTableDef.FieldDefs.Count)
         do begin
          if DbSettingTableDef.FieldDefs[i].FieldName = 'Rowid' then Continue;
          DbSettingTableDef.FieldDefs[i].DataType := ftMemo;
         end;
...