TBindings.Clear generated address error

Home Forums kbmMW TBindings.Clear generated address error

Viewing 6 reply threads
  • Author
    Posts
    • #55576
      TomYU
      Participant

      hi,kim

      FBindings:=TkbmMWBindings.Create;

      FBindings.Clear;

      When the Clear method is called for the second time, an address error occurs.

      kbmMW 5.14 has this problem, 5.13.10 is normal.

      procedure TkbmMWBindings.Clear;
      begin
      while TkbmMWInterlocked.Increment(FSyncUpdateRunning)>1 do
      begin
      TkbmMWInterlocked.Decrement(FSyncUpdateRunning);
      CheckSynchronize;
      end;

      DisableSyncUpdate;
      try
      FScheduler.UnScheduleGroup(‘RUN’);
      FSyncList.Clear;//The address generated by this line is wrong

      delphi 10.4.2+kbmMW 5.14

      best regards

      Tom YU

    • #55578
      TomYU
      Participant

      Because of this issue, I cannot upgrade to kbmMW 5.14!

    • #55592
      kimbomadsen
      Keymaster

      I’ve made a simple test like this:

      procedure TForm1.FormCreate(Sender: TObject);
      var
         FBindings:TkbmMWBindings;
      begin
           FBindings:=TkbmMWBindings.Create;
           FBindings.Clear;
           FBindings.Clear;
           FBindings.Free;
      end;

      which works perfectly well without any exceptions. Be aware that you _must_ free your binding instance before application closes.

    • #55594
      TomYU
      Participant

       

      procedure TListDialogFrame.PrepareView;
      begin
      if DisplayDataSet <> nil then
      begin
          ListViewSearchBox(ListView1).Text:='';
          FBindings.Clear;//*******************
          if KeyFieldName <> '' then
             FBindings.Bind(DisplayDataSet, KeyFieldName, ListView1, '');
          FBindings.Bind(DisplayDataSet,DisplayFieldName,ListView1,'#Caption');
          FBindings.Bind(DisplaydataSet,'@',ListView1,'@',[mwboTwoWay]); //双向绑定.位置同步.
          FBindings.Update;
          FBindings.UpdateEvent.Activate(True);
      end
      else
      begin
          FBindings.Clear;//*****************
          FillListFromDisplayStringList;
      end;
      end;
      
      • This reply was modified 4 years, 9 months ago by TomYU.
      • This reply was modified 4 years, 9 months ago by TomYU.
    • #55597
      TomYU
      Participant

      This problem is real in my actual project, for this reason I cannot upgrade to kbmMW 5.14.

    • #55600
      tomyu666
      Participant

      I see, the problem is caused by this line of code:

      FBindings.UpdateEvent.Activate(False);
      
      
      
      procedure TForm1.FormCreate(Sender: TObject);
      var
         FBindings:TkbmMWBindings;
      begin
           FBindings:=TkbmMWBindings.Create;
           FBindings.Clear;
           FBindings.UpdateEvent.Activate(False);
           FBindings.Clear;// An error 
           FBindings.Free;
      end;
      
      
      		
      	
    • #55603
      kimbomadsen
      Keymaster

      Hi,

      Yup because the update event _must_ have access to several internal resources, while at the same time it may run slightly async to the destruction of the smart binding instance. Hence the update event has the responsibility of releasing some stuff when it ends.

      I did not anticipate people wanting to deactivate the update event at any time, however I appreciate that it may be a wish in certain circumstances, why I (as mentioned in a different reply) have made a change that should fix it and leave the resources be, until it is really during a smart binding instance shutdown.

      /Kim

Viewing 6 reply threads
  • You must be logged in to reply to this topic.