I'm using Delphi 2007. Sometimes properties linking to components get lost. This is typically Action properties and lookupdatasets. I have a few times had some emergency bug fixes and sent out a version to customers with a somewhat catastrophic result due to this :-) Anyone know a way to verify that properties that are supposed to be set really are set, or a way to prevent this from happening?
To recap, if you need to pass data from Link through to the new component that's being rendered, pass Link s a state prop with the data you want to pass through. Then, to access the Link s state property from the component that's being rendered, use the useLocation Hook to get access to location.
In React, sharing state is accomplished by moving it up to the closest common ancestor of the components that need it. This is called “lifting state up”. We will remove the local state from the TemperatureInput and move it into the Calculator instead.
It will do nothing; you have to call render method to render the component again.
useRouteMatch. Provides access to the match object. If it is provided with no arguments, it returns the closest match in the component or its parents. A primary use case would be to construct nested paths.
You can assign such values in code, obviously.
More importantly though, you have to diff every file before committing to sourcecontrol. Always.
Make sure your dfm-files is text, not binary. Then it will be easy to see unwanted changes before check-in/commit.
Diffing everything have stopped a lot of potential blunders for me.
An automatic build and test-system would also give you some confidence in what you deliver.
You've received several good answers about how to detect when this does happen (up voted). But one way to prevent it from happening (sometimes) is to make sure that you have added all of the referenced units to your DPR. If you open a form, for example, which contains components that reference other components on a data module, and that data module has not been added to the DPR/project, you're almost guaranteed to have the IDE remove those references, because it removes references which it cannot determine are valid. If, on the other hand, the data module is in the DPR, then the IDE will be able to find it, and it is less likely to remove the references in the first place
Unfortunately, it still happens from time to time, so you still need to take the precautionary measures detailed in the other answers. But this will make things better, if you don't already do this.
Create dunit test project. Run test before release. Sound all bells when test fails.
You want a way to verify if the values are set correctly. Well, you can use unit tests for this. Just initiate a form, compare the properties and done.
Comparing the dfm's is also a good way ofcourse but it does not take into account changes due to changed defaults or changes in the code.
When you add a form, data module or frame to a project, the IDE inserts a little comment "tag" after the unit name in the dpr file. It has been my experience that if for any reason this tag is not present, the IDE is more prone to losing cross-module component references.
I wholeheartedly support the idea of always viewing differences before each commit to version control, if you are using such as thing.
I hate to say this but Source Code Control can help in these situations. Even with an emergency bug fix you should be checking everything into a source code repository (Perforce is my personal favorite). In a small fix you could see by what files have changed whether you have any changes you are not expecting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With