Why would a module be unsavable until another module is loaded?
Asked Answered
U

5

7

Most of the units I work on rely on a Data Module. One of the most annoying things I come accross is an error message telling me

Module X references another module and cannot be saved until Module Y is loaded.

Now, I'm sure there is a very good reason why CheckNoFixups raises this error while trying to WriteRootStream, and fails to save what is in effect a Text file (and hopefully this isn't followed by Catastrophic Failure where I must then restart the IDE while still unable to save my work.) but what is the good reason?

Why am I unable to click save without opening anothing text file containing various functions and objects much like any other unit? whats so special about a DataModule that means I can't save the source I'm working on until it's open, why aren't the 45 other units in the uses clause so important they must be open?

EDIT: It's Delphi 2007

the Declaration of the DataModule is :

unit DataMD;

TRepDataMod = class(TDataModule)
...
var
  RepDataMod: TRepDataMod;
Upside answered 10/3, 2010 at 10:34 Comment(2)
I got other issues the day I got this "module x references module y". See here for a possible fix: #2416627Predacious
I really hate how Delphi pretend to be a productive environment yet it makes you lose hours and hours with these annoying bugs.Predacious
F
1

If the DataModule is not part of the opened project the data aware objects in your form that reference the DataModule, cannot verify their reference and I think therefore the message comes up.

I only seen this message when I was porting an older project to a new Delphi version or were migrating to a new set of database components. In normal circumstances I haven't encountered this message.

In earlier versions I haven't seen the message and the form/unit could be saved, but the references that were in your dfm were magicly deleted.

Fibrovascular answered 10/3, 2010 at 16:18 Comment(2)
Sounds interesting, I've seen the same problem with old projects (disappering references), how do you fix it?Keg
@Harriv: The only way I found was assigning theses references in code rather than at design time. That always worked anything else didn't. If you are using some source control you should always check the diff of the dfm file before committing, so at least you can spot the problem when it occurs and can easily fix it by copying the lost lines back from the previous version of the file. Not an ideal solution either...Landowner
C
1

I have the same issue (Delphi 7).

I have an imagelist on a datamodule for usage throughout the whole application. It happens after a compile, if there is an syntax error. The IDE opens the (pas) file and I can correct the error.

But trying to save the file shows that message ("Module 'XXX' links to module 'YYY' which cannot be found in the current project. Do you whish to remove/redirect the links to another module?"). XXX is the file itself and YYY is the datamodule. The datamodule is included in the project and answering "Yes" to that question would remove all links in the dfm file.

So the only solution is pressing "No", which basically saves the pas file and close the file in the - this time pressing "No" to the question if the file should be saved (the pas is in fact already saved).

I have allready tried various workarounds butstill struggling.

Campbell answered 29/6, 2010 at 6:51 Comment(0)
T
1

For what it's worth, I encountered the same problem with a frame on a form. I finally fixed it by removing the frame and adding it back again. I made sure that any event handlers were hooked back up after adding the frame back to the form.

Tidal answered 19/3 at 17:8 Comment(1)
You can also edit the DFM directly, and delete any inherited chunks; where the form "caches" what the frame contains. That cache can get out of sync, and then the form is broken.Bicycle
B
0

Module X references another module and cannot be saved until Module Y is loaded.

Just look over X.dfm (X.fmx) for "Y" entries. What to do with them, it's your choise.

Bluish answered 23/6, 2013 at 10:54 Comment(0)
U
0

Make sure DataModule is part of the project. Not enough just to include on search-path or enter into dpr-file manually. Go through IDE and add the DataModule to the project.

Also make sure the DataModule dfm-resource has the same name as the unit.

Unpleasantness answered 14/1, 2016 at 16:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.