Recent

Author Topic: [RESOLVED] OnClick causes crash  (Read 10948 times)

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
[RESOLVED] OnClick causes crash
« on: January 06, 2011, 10:55:56 pm »
Hi everybody!

Little question: I dinamically create a new form with a progbar inside it, whom progression i manage into another procedure, referring to progbar with
Code: [Select]
tprogbar(findcomponent('nameofprogbar'));In the previous procedure, i set OnClick := @myprocedure; as in the example
Code: [Select]
with newform do
  ....
  with progbar do
    ...
    OnClick := @myprocedure;

Now... myprocedure(sender: tobject) is required to perform some actions among which there's newform.close.
Every time i click on progbar appears "project raised exception class 'external: sigsegv'" and source editor opens the control.inc file directly to row 1072
Code: [Select]
MouseUp(Button, KeysToShiftState(Keys), XPos, YPos);in DoMouseUp procedure.

Obviously, calling myprocedure without click event will get the goal.

So... am i doing anything wrong or could it be a bug?

Thanks.
« Last Edit: January 30, 2011, 07:12:32 pm by Riccardo Giuliani »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnClick causes crash
« Reply #1 on: January 06, 2011, 11:30:40 pm »
Is the component a TProgressBar?

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #2 on: January 06, 2011, 11:37:10 pm »
Quote
Yes; and to be sure i put
Code: [Select]
if Sender is TProgressBar then ShowMessage('prog');into myprocedure.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnClick causes crash
« Reply #3 on: January 06, 2011, 11:43:47 pm »
This occurs even if you run the program outside the IDE?

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #4 on: January 06, 2011, 11:46:14 pm »
I Get an Access Violation

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnClick causes crash
« Reply #5 on: January 06, 2011, 11:47:34 pm »
I think you should report it on BugTracker.

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #6 on: January 06, 2011, 11:54:05 pm »
Me too. Could you indicate a guide? (never done before)
Thanks again for your patience.  :)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnClick causes crash
« Reply #7 on: January 06, 2011, 11:57:32 pm »
http://bugs.freepascal.org/view_all_bug_page.php?project_id=1

Simply sign up and make a report, adding an example project.

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: OnClick causes crash
« Reply #8 on: January 06, 2011, 11:59:27 pm »
Now... myprocedure(sender: tobject) is required to perform some actions among which there's newform.close.

If closing newform also means destroying it then you destroy a component (progbar) in it's own eventhandler, which wil cause an AV I think.

Bart

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #9 on: January 07, 2011, 12:20:09 am »
Quote
If closing newform also means destroying it then you destroy a component (progbar) in it's own eventhandler, which wil cause an AV
So... should all code in myprocedure be executed with progbar still "alive"?
Isn't enough just to call it?

mas steindorff

  • Hero Member
  • *****
  • Posts: 532
Re: OnClick causes crash
« Reply #10 on: January 07, 2011, 02:43:38 am »
you should read the post about the use of "with"
are you setting newform.onclick or progressbar.onclick

try it without the with statements
windows 10 &11, Ubuntu 21+ - fpc 3.0.4, IDE 2.0 general releases

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #11 on: January 07, 2011, 12:10:43 pm »
Quote
are you setting newform.onclick or progressbar.onclick
progressbar.onclick

Tried to find post you're talking about, but there are to much, so i googled around and i haven't found my problem is related to "with do", but i'll test without the statement.

Maybe Bart's right.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: OnClick causes crash
« Reply #12 on: January 09, 2011, 09:23:10 pm »
Why do you need to click on a TProgressBar?

Riccardo Giuliani

  • New Member
  • *
  • Posts: 40
Re: OnClick causes crash
« Reply #13 on: January 14, 2011, 05:55:36 pm »
Sorry for delay, been occupied.
Quote
Why do you need to click on a TProgressBar?
Just because i thought this gentle solution to my application.
At last i've statically created a form with a progbar inside, resolving everything.

Should i put RESOLVED on title?

Thank you all.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Re: OnClick causes crash
« Reply #14 on: January 25, 2011, 10:40:22 am »
Should i put RESOLVED on title?
Not required, but maybe nice to other ppl reading this.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018