views:

580

answers:

4

I've been meaning to ask this question for a while, at least 4 times a day I need to restart Delphi to get the debugger to stop at breakpoints again. Sometimes I can trick it into working again by attaching to the process after a rebuild of the code. But most of the time I can't and it is costing me a lot of time to go back and re-open all the files that I want.

Nearly every time this happens I do get some sort of Fatal Error when trying to close Delphi. Is there any fix for this? I've got the "latest" Delphi 7, running on winXP with plenty of memory. Most of the other guys in my office get this problem too.

+2  A: 

While you are debugging, do you exit the program normally, or do you use the IDE to force debugging to stop / kill the application? I have found that using the IDE to force the application down causes problems after a while (resolved by restarting the IDE), while exiting the program from within the application causes no such trouble.

Caveat: my experience is with Delphi 6.

Scott W
+3  A: 

Our experience with Delphi 7 is similar to yours: Fairly constant crashes within the IDE, with abstract errors, invalid pointer references, and exceptions in the VCL library.

It seems to depend on the complexity of the project you have loaded: Our main project is a 200,000+ line program with multiple MDI forms and third-party libraries. Virtually whenever we'd exit Delphi we'd have to deal with catastrophic fatal errors. We got very adept at using the task manager to hunt down the Delphi32 process and kill it -- virtually the only way to get out sometimes.

We've since upgraded to Delphi 2009 and it has significantly better stability. My feeling is that Delphi 7 has numerous bugs, and you will either have to live with them, or upgrade.

+1  A: 

I've had this in D7 too - but really only with one particular project (admittedly very large, many many forms and home-brewed custom components). Other projects (some equally large) were fine.

My feeling was that it was somehow related to using frames and/or forms that were subclassed from other frames/forms, where you would have the descendant form open in the IDE/debugger but not the ancestor form.

Because, just like you, I felt it was a monstrous pain to shut down and restart the IDE half a dozen times a day, I took the trouble to create a .DSK file for the project, that had all the parent form stuff in it, so that when Delphi started-up that project it opened all those other forms 'automatically'. Once I was sure I'd got the contents of the DSK right, I made the .DSK file read only...!

It meant that the editor would 'forget' which files I had open at the time, but at least it would always automatically open up all the stuff that seemed to make the IDE 'behave'. If I was going to be working on a particular handful of files for a few days, I'd just manually add them to the .DSK file.

I seem to recall that Delphi would make some passing complaint about the file being read-only, but this method took away about 80% of our daily pain.

And then the other thing I did was to have the Task Manager load up, minimized, as part of my system startup. At least then it was a simple case of ALT-TAB to get to something that could kill the IDE. :-)

robsoft
Tip 1: Ctrl+Shift+Esc is the shortcut for the Task Manager, works also if it's not started at system startup. Tip 2: Proces Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) can be set to replace the Task Manager (same kbd shortcut) and does a lot more. Highly recommended!
mghie
Thanks mghie - all good information there! :-)
robsoft
How do you make a .DSK file? I've deleted my .DST files and that didn't help. I saw this which looked similar to what you were saying.http://www.advanceis.com/delphi-cppb/articles/delphi-workaround-for-delphi-shutdown-av.htmlBut I don't know what a .DSK file contains.
Peter Turner
The DSK is the 'desktop' file, it contains info about the files you had open in the IDE (amongst other things). If you check the environment option to 'save desktop' then Delphi will make/update a dsk file in the folder alongside your project. I'll make a simple example and post it here shortly!
robsoft
That article you linked is interesting, but in the end all they are suggesting really is a more flexible and elegant way of protecting the dsk. I actually quite like their approach - Delphi doesn't much like you making the DSK file readonly, which is my cheap and cheerful fix. :-)
robsoft
+1  A: 

Okay, following on from my pervious response in this question, here's a sample DSK file. I can't post this as a comment to my response otherwise I would. :-)

There's really nothing much to them, they're quite straightforward and a glance through this ought to help you see this. I'd actually advise that you just load up Delphi, switch on the 'autosave desktop' option (it's in Environment or Editor, I forget which), arrange the IDE as you want it (with the various source files open, etc), then save/close the project. You will find a MyProject.dsk (etc) file in the project directory - just make that read-only (or follow the advice in the article you linked to in the comments, and make a backup copy of it somewhere that you can always bring back whenever you need to).

Anyway, here's a sample DSK to give you an idea of what you're playing with. They are just INI-type text files, you can hack them in Notepad if you so wish. :-)

[Modules]
Module0=C:\Projects\GUIPlay\src\du_FrameUtils.pas
Module1=C:\Projects\GUIPlay\src\du_BaseDialogs.pas
Module2=C:\Projects\GUIPlay\src\dm_DataMain.pas
Module3=C:\Projects\GUIPlay\src\du_Main.pas
Count=4
EditWindowCount=1

[C:\Projects\GUIPlay\src\du_FrameUtils.pas]
ModuleType=SourceModule
FormState=1
FormOnTop=0

[C:\Projects\GUIPlay\src\du_BaseDialogs.pas]
ModuleType=SourceModule
FormState=1
FormOnTop=0

[C:\Projects\GUIPlay\src\dm_DataMain.pas]
ModuleType=SourceModule
FormState=1
FormOnTop=1

[C:\Projects\GUIPlay\src\du_Main.pas]
ModuleType=SourceModule
FormState=1
FormOnTop=1

[C:\Program Files\Borland\Delphi7\Projects\ProjectGroup1.bpg]
FormState=0
FormOnTop=0

[C:\Projects\GUIPlay\src\GUIPlay.dpr]
FormState=0
FormOnTop=0

[C:\Projects\GUIPlay\src\GUIPlay.todo]
FormState=0
FormOnTop=0

[EditWindow0]
ViewCount=4
CurrentView=2
View0=0
View1=1
View2=2
View3=3
CodeExplorer=CodeExplorer@EditWindow0
MessageView=MessageView@EditWindow0
Create=1
Visible=1
State=0
Left=212
Top=157
Width=1127
Height=757
MaxLeft=-1
MaxTop=-1
ClientWidth=1119
ClientHeight=723
LeftPanelSize=140
LeftPanelClients=CodeExplorer@EditWindow0
LeftPanelData=000004000000000000000000000000000000000000000000000100000000000000000C000000436F64654578706C6F726572FFFFFFFF
RightPanelSize=0
BottomPanelSize=0
BottomPanelClients=MessageView@EditWindow0
BottomPanelData=00000400010000000B0000004D6573736167655669657700000000000000000000000000000000000100000000000000000B0000004D65737361676556696577FFFFFFFF

[View0]
Module=C:\Projects\GUIPlay\src\du_FrameUtils.pas
CursorX=1
CursorY=1
TopLine=1
LeftCol=1

[View1]
Module=C:\Projects\GUIPlay\src\du_BaseDialogs.pas
CursorX=1
CursorY=1
TopLine=1
LeftCol=1

[View2]
Module=C:\Projects\GUIPlay\src\dm_DataMain.pas
CursorX=1
CursorY=1
TopLine=1
LeftCol=1

[View3]
Module=C:\Projects\GUIPlay\src\du_Main.pas
CursorX=1
CursorY=1
TopLine=1
LeftCol=1

[Watches]
Count=0

[Breakpoints]
Count=0

[AddressBreakpoints]
Count=0

[Main Window]
Create=1
Visible=1
State=2
Left=0
Top=0
Width=1571
Height=143
MaxLeft=-1
MaxTop=-1
MaxWidth=1579
MaxHeight=143
ClientWidth=1571
ClientHeight=109

[ProjectManager]
Create=1
Visible=1
State=0
Left=1188
Top=135
Width=345
Height=762
MaxLeft=-1
MaxTop=-1
ClientWidth=337
ClientHeight=736
TBDockHeight=305
LRDockWidth=438
Dockable=1

[AlignmentPalette]
Create=1
Visible=0
State=0
Left=200
Top=144
Width=156
Height=84
MaxLeft=-1
MaxTop=-1
ClientWidth=150
ClientHeight=60

[PropertyInspector]
Create=1
Visible=1
State=0
Left=3
Top=147
Width=272
Height=783
MaxLeft=-1
MaxTop=-1
ClientWidth=264
ClientHeight=757
TBDockHeight=783
LRDockWidth=272
Dockable=1
SplitPos=85
ArrangeBy=Name
SelectedItem=Name
ExpandedItems=
HiddenCategories=

[ObjectTree]
Create=1
Visible=0
State=0
Left=0
Top=142
Width=190
Height=314
MaxLeft=-1
MaxTop=-1
ClientWidth=182
ClientHeight=288
TBDockHeight=314
LRDockWidth=190
Dockable=1

[CodeExplorer@EditWindow0]
Create=1
Visible=1
State=0
Left=0
Top=12
Width=140
Height=711
MaxLeft=-1
MaxTop=-1
ClientWidth=140
ClientHeight=711
TBDockHeight=305
LRDockWidth=140
Dockable=1

[MessageView@EditWindow0]
Create=1
Visible=0
State=0
Left=12
Top=0
Width=1107
Height=66
MaxLeft=-1
MaxTop=-1
ClientWidth=1107
ClientHeight=66
TBDockHeight=66
LRDockWidth=443
Dockable=1

[DockHosts]
DockHostCount=0

As you can see, really it's a list of files to re-open, along with some sense of the position/size of the windows and the order in which to open the files.

Best of luck! :-)

robsoft