Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Access violation because GDriveItems is NIL

 Post Reply Post Reply
Author
Schröder Heiko View Drop Down
Member
Member
Avatar

Joined: 30 Nov 2010
Posts: 52
Post Options Post Options   Quote Schröder Heiko Quote  Post ReplyReply Direct Link To This Post Topic: Access violation because GDriveItems is NIL
    Posted: 08 May 2019 at 5:42pm
Hello,

I hope you can help me. 
Following you will find my function to get a file list from an known FolderID in Google Drive.
But the problem is the red marked line throws an exception because the GDribveItems are NIL.
Did I initiate the variable wrong?
 

function Get_Filelist_GDrive(TMSStorage : TTMSFMXCloudGDrive; out GDriveItems: TGDriveItems)  : Boolean;
var
  myFolder, CI_Folder : TGDriveItem;
  i: Integer;
  FolderID: string;
begin
  // FolderID is saved and known
   myFolder := TGDriveItem.Create(NIL);
    try
      myFolder.ID := FolderID;
      GDriveItems := TGDriveItems.Create(TMSStorage, NIL);
      GDriveItems := TGDriveItems(TMSStorage.GetFolderList(myFolder));
      for i := 0 to GDriveItems.Count-1 do
      begin
        // get files
      end;
    finally
      myFolder.Free;
    end;
end;
Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2192
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 09 May 2019 at 9:31am
Hi,

Your sample code seems to be working as expected when tested here.
Can you try to enable logging to find out if any errors were encountered?
Logging can be enabled by setting Logging to True and LogLevel to llDetail.
The LOG file is automatically generated in the machine's Documents folder.
Back to Top
Schröder Heiko View Drop Down
Member
Member
Avatar

Joined: 30 Nov 2010
Posts: 52
Post Options Post Options   Quote Schröder Heiko Quote  Post ReplyReply Direct Link To This Post Posted: 09 May 2019 at 5:06pm
Hello,

I thought Looging isn't possible for Android. Does it?
If I try to compile this app to Windows then the IDE doesn't find Controls and Forms in Cloudbase.pas
Back to Top
Schröder Heiko View Drop Down
Member
Member
Avatar

Joined: 30 Nov 2010
Posts: 52
Post Options Post Options   Quote Schröder Heiko Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2019 at 1:17pm
I found a solution:

function Get_Filelist_GDrive(TMSStorage : TTMSFMXCloudGDrive; out GDriveItems: TGDriveItems)  : Boolean;
var
  myFolder, CI_Folder : TGDriveItem;
  i: Integer;
  FolderID: string;
  tmpItems : TTMSFMXCloudItems;
begin
  // FolderID is saved and known
   myFolder := TGDriveItem.Create(NIL);
    try
      myFolder.ID := FolderID;
      GDriveItems := TGDriveItems.Create(TMSStorage, NIL);
      tmpItems := TMSStorage.GetFolderList(myFolder);
      if tmpItems <> NIL then
      begin
        GDriveItems := TGDriveItems(tmpItems);
        for i := 0 to GDriveItems.Count-1 do
        begin
           // get files
        end;
      end;
    finally
      myFolder.Free;
    end;
end;
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down