INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ShowModal crash but Show OK - help!

ShowModal crash but Show OK - help!

(OP)
Hi All,

Weird thing has started happening to a program I have been developing in my spare time for months.

I have a search dialog that I "ShowModal" and it has started throwing an Exception on Close. If I change the call to "Show" it close OK with no exception.

I have stepped through it and it does not take me to where the exception is. I used the CallStack window but that just shows the original call. I have removed stuff and disabled all manner of stuff but still it persists with ShowModal. The actual Search process all works fine, the problem arises just after the "Close" statement in the Search dialog.

Any thoughts to help me clear this up?

Thanks

RE: ShowModal crash but Show OK - help!

Perhaps you are Freeing the form twice. When you open the form via a ShowModal, I assume you are doing so like:

CODE

NewForm := TForm2.Create(...);
try
   NewForm.ShowModal
   if NewForm.ModalResult = mrOK then
      //do stuff
finally
   NewForm.Free;//object freed here.
end; 

Also, if you have OnClose defined like so in the form you are opening

CODE

TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   Action := caFree;//Sets to free the object.
end; 

In this case, your code would attempt to free the form twice, the second attempt would generate an access violation. This wouldn't happen if you "show" the form because you wouldn't free the form depending on the form's modal result.

RE: ShowModal crash but Show OK - help!

(OP)
@majlumbo:
Thanks, not quite the issue but it did make me look in the Show and OnClose events. It is something to do with the SQLite database that was being reset in the OnClose. Have not quite tracked it down, but now I am on the right path. Thanks a bunch that drove me nuts for several hours.

The key you gave me was the Show does not free the form. From there it was an easy track to the SQLite area. I will have to see what I have recently changed there.

Much appreciated.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close