Dave Novo 57 Posted Thursday at 10:56 PM (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 Thursday at 10:59 PM by Dave Novo Share this post Link to post
Lajos Juhász 325 Posted yesterday at 06:51 AM 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 yesterday at 11:16 AM (edited) 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. Edit: @Uwe Raabe found out that it seems to be related to the property having a getter that is a function - when that is the case, it shows the value - otherwise, a field or property with direct field read access does not. I would call that a bug in the debugger Edited 23 hours ago by Stefan Glienke Share this post Link to post
Dave Novo 57 Posted 16 hours ago (edited) I don't think its as simple as that. Here is a real case from my production code. Both the variables 'allData' and 'recoveredMixMat' are of type IShared<MtxH.MtxWithHeader.TMtxWithHeader>, yet one can be debugged and the other cannot. In this case, both variables were created exactly the same by calling NewMtxHFromFile which loads a data file from disk and returning a IShared<MtxH.MtxWithHeader.TMtxWithHeader> yet the watch list I think the debugger is messed up in many different ways, both with inline variable declaration and dealing with anonymous functions that return objects. Other times I have gotten that the IShared variable is simple "inaccessible", which usually can be cleared up by doing "Allow side effects and function calls" but it does not resolve these. Edited 16 hours ago by Dave Novo Share this post Link to post