Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-07

Newbie: Greeting and ask how to add a patch?

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Raditya Perdhevi

hi all,
i don't know if this is the right place to ask but i have a stupid question how can i add a patch?
some time ago i've added a small adjustment on RX component from Lazarus-CCR, to be exactly, i've added this lines on rxlookup.pas on OnClosePopup method in TRxCustomDBLookupEdit class

  if assigned(FRxPopUpForm) then
  begin
    FRxPopUpForm := nil;
  end;

it deals with the behaviour when lookupEdit is clicked twice and on second click the PopUpForm didn't showup.

i don't know how can i do the regression test, so let's just say i'm putting the code with my finger crossed.

i'm sorry if this mail is addressed in wrong placed, because i never joined any opensource project before.

with all the passion
Perdhevi

-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090728/7b5dd2a7/attachment.html>

Reply by email

Christian Iversen
to Raditya Perdhevi
Raditya Perdhevi wrote
hi all, i don't know if this is the right place to ask but i have a stupid question how can i add a patch?

It certainly is! Although I'm not involved enough with the project to be totally sure, unfortunately :)

Show quoted text 8 lines
some time ago i've added a small adjustment on RX component from Lazarus-CCR, to be exactly, i've added this lines on rxlookup.pas on OnClosePopup method in TRxCustomDBLookupEdit class if assigned(FRxPopUpForm) then begin FRxPopUpForm := nil; end;

This just seems superfluous. Isn't the FRxPopUpForm just a straight variable? Then just assign nil to it. There should be no need to check it for non-nility when you're just going to nil it anyway.

Med venlig hilsen Christian Iversen

Reply by email

Leslie Kaye
to Christian Iversen
Christian Iversen wrote 9 lines
<div class="moz-text-flowed" style="font-family: -moz-fixed">On 2009-07-28 12:08, Raditya Perdhevi wrote: > hi all, > i don't know if this is the right place to ask but i have a stupid > question > how can i add a patch? It certainly is! Although I'm not involved enough with the project to be totally sure, unfortunately :)

Patches are created and applied with a subversion client http://en.wikipedia.org/wiki/Comparison_of_Subversion_clients Also see the Lazarus wiki about getting the latest SVN trunc Lazarus code If you want to submit a patch then create a bug report about the issue and upload your patch file to the bug report. If it is a good patch then one of the project managers will apply it to the product. Actually I think it should be compulsory to submit a patch with bug reports - maybe more would get resolved!!

Show quoted text 14 lines
> some time ago i've added a small adjustment on RX component from > Lazarus-CCR, to be exactly, i've added this lines on rxlookup.pas > on OnClosePopup method in TRxCustomDBLookupEdit class > > if assigned(FRxPopUpForm) then > begin > FRxPopUpForm := nil; > end; This just seems superfluous. Isn't the FRxPopUpForm just a straight variable? Then just assign nil to it. There should be no need to check it for non-nility when you're just going to nil it anyway.

I worry about this code. Does the FRxPopUpForm get freed elsewhere? Without garbage collection you need to be wary of memory leaks.

I have not looked at the source you are working on so forgive me if the following comment is not applicable. It may in any case be a good tip for others on the mailing list.

To trash FRxPopUpForm you could

FRxPopUpForm.Free;
FRxPopUpForm := nil;

Free checks for nil so you do not get an access violation even if it is already nil

Application forms should be created with the Application.CreateForm method so they get added to the Application's Forms list, to be drawn in the correct order and honour any fsStayOnTop settings. It should be left to the application to clean them up on exit.

Component related forms (as I think is the case that you are talking about) (or any other component you need to point to - not just forms) which are pointed to by a component field (F variable) (rather than by a local (method) variable) should best use the TComponent Notification procedure to nil the field if the form can be destroyed at run time before the component is destroyed

If you are creating the form in your component ...

FRxPopUpForm.Create(  {Self, nil or whatever});
FRxPopUpForm.FreeNotification(Self)

Otherwise if the RxPopUpForm already exists external to your component and you want to know if it gets destroyed ...

Declare a property in your component...

property RxPopUpForm : TRxPopUpForm read FRxPopUpForm write SetRxPopUpForm;

then implement the property setter

procedure TMyComponent.SetRxPopUpForm(Value: TRxPopUpForm );
begin
  if  (Value = FRxPopUpForm) then
    Exit;
  if Assigned(FRxPopUpForm) then
    FRxPopUpForm.RemoveFreeNotification(Self);
  FRxPopUpForm := Value;
  if Assigned(FRxPopUpForm) then
    FRxPopUpForm.FreeNotification(Self);
end

Either way you write a notification override procedure to nil the property.

procedure TMyComponent.Notification(AComponent: TComponent; Operation:
TOperation);
begin
  inherited Notification(AComponent, Operation);
  case Operation of
  opRemove:
    if   (AComponent =  FRxPopUpForm) then
      FRxPopUpForm := nil;
  end; // case
end

in this way you can free the FRxPopUpForm instance anywhere at any time and your component will know that it is now nil.

if you are creating and destroying FRxPopUpForm inside a method you just protect the code with a try .. finally block to make sure that you clean up the memory allocation.

Hope this is of help to somebody!

Reply by email

waldo kitty
to Leslie Kaye
Leslie Kaye wrote
Actually I think it should be compulsory to submit a patch with bug reports - maybe more would get resolved!!

feh! that's rather counter intuitive and/or self-defeating, isn't it??

think about it for a sec... someone may be able to describe a bug but have no idea how to fix it so there's no way they could present a patch with the bug report ;)

Reply by email