Be careful not to create Münchhausen packages!

Be careful not to create Münchhausen packages!
There are stories about the German Baron Münchhausen which gives the impression that this man must be the ancient founder of the Impossible Mission Forces. In one of these stories the baron rescues himself from a swamp by tearing himself on his own hair.
Some Delphi packages seem to be written in honor of the baron. They use components in their forms that are actually not registered until the package itself is loaded. This leads to the problem that opening such a form while the package is not loaded yet, say because of a compilation error or a stray DSK file, those components are removed from the DFM file. Be sure to revert to a previous version then.
Please, do me a favor: Either use only standard components in your packages or make sure that any form making use of those custom components is in a separate package, so that the component package can be compiled and installed as a prerequisite.
https://de.wikipedia.org/wiki/Hieronymus_Carl_Friedrich_von_M%C3%BCnchhausen

Comments

  1. That's no problem unless you let the IDE remove these components. And who in their right mind ever does that?

    ReplyDelete
  2. Thomas Mueller Well, the IDE simply doesn't create those components when opening the form (how could it) and asks you - when saving - to remove the references to them in the PAS file - so better not save the DFM with these changes. But what when you want to change the PAS file because you have to fix some errors? You can either save both or none. Even denying the confirmations asked by the IDE when saving the PAS about removing these references will still remove the components from the DFM (they simply don't exist in the instance), although they stay in the PAS. A workaround is to edit the PAS with an external editor.

    ReplyDelete
  3. Uwe Raabe so far the IDE has always asked me if I want to remove the components when I open the form. If I Cancel (not Ignore!) it, it will not show the form but only the Pascal source code. Then I can change code to my liking and simply save it, without the IDE touching the .dfm file.

    ReplyDelete
  4. Thomas Mueller Correct! Not opening the form in the first place is another way to go.

    ReplyDelete

Post a Comment