-1

I have an component on my form (a TPushEvents). I've explicitly removed the value from one of it properties (Provider).

I've saved and checked it into source control. I can see that the property is indeed removed from fmx file. Here's what the entry looks like after I blank the property and save the form:

object PushEvents1: TPushEvents
  Left = 128
  Top = 200
end

If I close the project and re-open it, the property is re-added and reset to it's default (it's pointed at the first T*Provider component it can find on the form - in my case a TKinveyProvider). This causes me all kinds of grief when building in release mode. Here's what the entry looks like after I re-open the project save the form:

object PushEvents1: TPushEvents
  Provider = KinveyProvider1
  Left = 128
  Top = 200
end

And indeed saving it, I can see that the property has been returned to the fmx file.

Setting the property to nil in the FormCreate is no good because the TPushEvents starts accessing the TKinveyProvider before the FormCreate is triggered.

How can I keep TPushEvents.Provider property nil when I reload the project?

In my ideal world, I'd be able to enter a constant that would allow it to keep the property in the fmx file, but still indicate that it wasn't pointing at anything.

BIBD
  • 15,107
  • 25
  • 85
  • 137
  • Create "procedure Loaded; override;" and try setting it in Loaded after the call to inherited. – FredS May 16 '16 at 21:07
  • 1
    Is this object from FMX or your own / third party? If possible, it would be the best solution to fix this component. I made the same mistake with my components: set some initial values in constructor hoping that actual values would be 'loaded' from file, but it turned out that only properties explicitly stored in files are changed, so constructor MUST set values to default by itself, there is nice method described in 'Delphi in a Nutshell' book to automatically set all properties to their default values. – Yuriy Afanasenkov May 16 '16 at 21:13
  • @YuriyAfanasenkov Short story is it's a TPushEvent object. So it's built in from Embarcadero so that'll require some spelunking. My big hope was that there was a way to hard code Nil as a parameter of the object in the designer view. – BIBD May 16 '16 at 21:25
  • Very hard to advise you when the question is so hypothetical. If we had a [mcve] we'd know what you were referring to. – David Heffernan May 17 '16 at 11:56
  • I've made the question a lot less hypothetical now. – BIBD May 17 '16 at 15:03
  • I can't recreate your problem. Are you sure that upon loading of project Delphi does read those FMX files that does not have that property set? Perhaps Delphi is loading FXM files from a different location that you are expecting or maybe an older version of those. There is no other logical explanation of why this would be happening – SilverWarior May 17 '16 at 16:39
  • I just re-tested to the same effect. Did you close the whole project? It even does this when saving & closing and re-opening the form. Is there an option that says something like "Do/Don't update missing parameters for controls" that I've missed? – BIBD May 17 '16 at 20:41

1 Answers1

0

I have found a less than ideal solution.

If I move the entire creation of the the TPushEvents component into the FormCreate then I don't have to worry about the component being "fixed" by RAD Studio when I re-open my project.

What makes it less than ideal is if I'm following the apparent philosophy of the product (drop components on the form instead of creating them in code) then this is certainly stepping out of that model.

BIBD
  • 15,107
  • 25
  • 85
  • 137