Jump to content
Registration disabled at the moment Read more... ×
Dave Novo

Debugging Reliably with IShared - Spring4D

Recommended Posts

I love using IShared with Spring4D. Particularly with inline variable declaration.  However, the debugger behaves so finicky and random. See the following example

 

screenshot1.thumb.png.70827970c17dafb22a4782d17cac233c.png

 

For some reason, I can debug SharedBmp just fine, but not sharedForm. In this case, it does not matter if I use inline variable declaration or put it in the var section of the method. It also does not matter if I click "Al;low side effects and function calls". I cannot debug sharedForm.

 

This is just an example. It has nothing to do with using Shared<T>.Make vs Shared.Make<T> variants. It randomly works or not either way. If I introduce a temporary variable with inline declaration, I can debug again

 

image.thumb.png.477bb634b8bd32a853a2ec8200299d62.png

 

but that means that I realize I need to debug something I need to recompile. I have tried lots of variants, like sharedForm().Width in the Watch list but it never works. Is there a trick to make IShared reliably work with the debugger?

 

Sorry about the small screenshots. I have no idea why they look so small. They look much larger in Paint before I paste them into the editor.

 

 

 

Edited by Dave Novo

Share this post


Link to post

This seems to have nothing to do with IShared, but somehow the debugger is stumbling over something - interestingly enough, it does not even work with the simplest classes. It rather seems that Vcl.Graphics.TBitmap is special somehow, as that is the one I see it working on :classic_laugh:

 

uses
  System.SysUtils,
  Vcl.Graphics;

type
  TFoo = class
    Width, Height: Integer;
  end;

  TBitmap = class // comment out this class and sharedMap will work
    Width, Height: Integer;
  end;

procedure Test;
begin
  var map := TBitmap.Create;
  var sharedMap := function: TBitmap begin Result := map end;
  sharedMap.Width := 100;
  sharedMap.Height := 100;

  var foo := TFoo.Create;
  var sharedFoo := function: TFoo begin Result := foo end;
  sharedFoo.Width := 100;
  sharedFoo.Height := 100;
end;

begin
  Test;
end.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×