Dave Novo 57 Posted 12 hours ago (edited) I love using IShared with Spring4D. Particularly with inline variable declaration. However, the debugger behaves so finicky and random. See the following example 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 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 12 hours ago by Dave Novo Share this post Link to post
Lajos Juhász 325 Posted 4 hours ago You can try to check "Allow Side Effects and Function Calls" in some cases that can help. https://docwiki.embarcadero.com/RADStudio/Athens/en/Watch_Properties (When a property has a getter method the IDE can give "Inaccessible value".) Share this post Link to post
Stefan Glienke 2148 Posted 33 minutes ago 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 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