Forum > Graphics

Another external sigsegv problem


I have been doing a lot of Google-ing trying to find an answer to my problem and while there it does seem to be fairly common can't find anything that is directly applicable. I am running Lazarus on  Ubuntu and for the moment am trying to write some short routines that initialize  the image of an image box at runtime, then change the image  when the image box is right clicked.

Here is the relevant code, it compiles okay but I get an "external sigsegv" exception when it runs. (occasionaly I get a 216 error on a second attempt at running.)

--- Quote ---Procedure Set_image;
    Form1.icon_map.GetBitmap(0, Form1.X1Y1.Picture.Bitmap); //external sigsegv
     state := 'img1'

procedure TForm1.X1Y1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
     If Button = mbRight Then
           If state = 'img1'   Then
                  Form1.icon_map.GetBitmap(1, Form1.X1Y1.Picture.Bitmap);
                  state := 'img2'
              If state = 'img2'  Then
                    Form1.icon_map.GetBitmap(2, Form1.X1Y1.Picture.Bitmap);
                    state := 'img3'
                      Form1.icon_map.GetBitmap(0, Form1.X1Y1.Picture.Bitmap);
                      state := 'img1'

--- End quote ---

I would be grateful if someone could help out with this, the breadth and variety of posted reasons for this error is astounding.

What is Form1.icon_map and when is Set_image called

Please give us a compilable example showing your problem. With the individual lines is nothing wrong.

It would be helpful if you told us what these cryptic names mean.
I guess "icon_map" is a TImageList and "X1Y1" is a TImage, right?
I cannot reproduce the problem in this case.
What is your Lazarus Version and OS?
When are you calling Set_image?

SIGSEGV means the same as "access violation". It is rather unspecific, see:

EDIT: Sry Marc, you were faster ;-)

Thanks for responding, I kept on Google-ing and  managed to figure out what was wrong and was posting this  post as solved when you replied.

Basically I was not initializing the Timage properly. I thought I was and it compiled okay, but.....

For anyone else searching these forums the Wikipedia article on "external sigsegv errors" puts everything in the correct context and thus helps a lot.

Also, just to finish:

        "Form1.icon_map" is a TimageList
        Set_image is  called by TForm1.FormCreate at form creation.

That was the mistake I was making, I was trying to initialize it during the initialization section. (Okay, so I am stupid. but I learned Pascal a very long time ago and Objects really make me feel like a dinosaur.)

Anyway, thank you for your prompt attention.



[0] Message Index

Go to full version