Recent

Author Topic: Array of 16 timages works, but at 17 it ends with no error message  (Read 270 times)

steveinalabama

  • New Member
  • *
  • Posts: 24
I have a Lazarus program that has a TMemo of 20 - 30 file names of jpg files.
The intention is to show a bunch of thumbnail type images, like what you see
in File Explorer if you set the view to "large icons", but this program is not
restricted to a single folder.
I have an array of timages which are created on form activate with
    myarray := TImage.Create(self);
    myarray.Parent := form1;
    myarray.stretch := true;

and on a buttonclick is loaded with  myarray.picture.loadfromfile(memo1.lines[i-1]); 
It works fine with 16 or less timages in the array. I intended to create the array using a hardcoded variable set to 10 for testing.
It failed with access violations because the hard coded global public variable mysteriously changed from 10 to 3 plus million
between the form.onactivate and button click. I solved it easily be changing the variable to a const:  num_images = 10;

When I change the constant value to 16 it still works, but when I change it to 17 it fails with no error message, just ends
 
I have coding that adds maybe 100 to each timage.left value, and when (I mod 5 = 0)  it sets the left value back to the left value of the first timage, and
increments the image.top value by 100 or so.   With the constant set to 16, it correctly shows 5 images aligned on the form, then a second and third set of 5
images aligned on the form, each group of 5 at the same height, It works showing a 16th image on the 4th "line" on the form, but when I changed the constant to 17 it abruptly ends with no error message.

Earlier it was ending with access violations, and I changed the minimum stack size and heapsize {$M 7000000000,7000000000}, and now it immediately ends with no error message.
The computer has 16 gig of memory, so I entered 7gig as stack and heap; If I comment that out, it makes no difference.
As I stated, It runs fine with 16 but not with 17 timages in the array.

Does anyone have a clue as too what is causing this problem? Thank you.

AlexTP

  • Hero Member
  • *****
  • Posts: 1900
    • UVviewsoft
Re: Array of 16 timages works, but at 17 it ends with no error message
« Reply #1 on: June 20, 2022, 12:00:57 am »
Maybe create the small compileable project which exposes the problem?

steveinalabama

  • New Member
  • *
  • Posts: 24
Re: Array of 16 timages works, but at 17 it ends with no error message
« Reply #2 on: June 20, 2022, 12:41:00 am »
problem solved. Another case of my own stupidity.

I really thought my_array was declared as array [1..100] of timage but it was [1..10];Duhhhhhhh !


steveinalabama

  • New Member
  • *
  • Posts: 24
sorry for making another post just to mark it as "closed" or "resolved"

dseligo

  • Hero Member
  • *****
  • Posts: 718
sorry for making another post just to mark it as "closed" or "resolved"

Change subject of your first message to: [SOLVED] Array of 16 timages works, but at 17 it ends with no error message

 

TinyPortal © 2005-2018