Page 1 of 1

Runtime error 216 in my app if only window in taskbar

Posted: Thu Sep 06, 2007 5:35 pm
by 9534808
Hi there - I've been tracking down a weird error in my application - if its the only application running, and I close it I get several errors as follows:

The instruction at "0x...." referenced memory at "0x....". The memory could not be "read".

Runtime error 216 at 50423C1E

I think this might be related to TeeChart (or my use of it) as if I recompile my app without the TeeChart functionality I don't get this error.

I also don't get this error if I have another application running (anything - notepad, explorer etc. ) I think this might be because that other application get focus and not the desktop.

I also only get this error when I do something that causes my app to redraw its chart (so opening it up on a data set that draws the initial graph is ok)- when I update data I redo a removeAllSeries, set the X and Y title caption and redraw my series on the graph.

I also don't get this error on Vista - only on XP (haven't tested lower). I have tried upgrading to the lasted 2.1.4 ocx (previously was 2.1.3) and it hasn't made a difference.

I am using the control as an ActiveX component from Dolphin Smalltalk - and I don't explicitly free anything when closing (the Dolphin framework does that for me) - I've not had any problems with other controls but potentially I need to do something different? The error doesn't seem to be a smalltalk error - and I don't get any smalltalk stack dump like I do with other errors.

Do you have any tips for me?

My application can be downloaded at: www.iterex.co.uk (its called Iterex Professional - its available in the side bar). Like I said you have to open the app from the Start Menu with no other applications open, and then you have change the created date of the first card and close the app.

Any help greatly appreciated.

Tim

Any further thoughts on this?

Posted: Fri Sep 07, 2007 7:24 pm
by 9534808
While waiting for a reply I did some more experiments to see if I'm doing something wrong or if I can eliminate TChart as the culprit.

I have noticed that if I change my app, catch the closing event of my application and for the two graphs that I display I do:
ClearChart and Close

Then I don't get the error. However I do get the error if I have a prompt box for Save Changes - so it seems like some timing thing.

It would be helpful if you had any ideas of things I can try.

thanks,

Tim

Posted: Sun Sep 09, 2007 11:48 pm
by 9534808
Another interesting point on this subject -

If I open my app and show a graph and then close it - I exit without any errors.

However, if I right click on my graph and show the TChart Settings dialog (I trap the right click mouse event, show a menu and then call the Settings function) - if I close the dialog with no change and then exit my app - I get the memory fault and runtime error as well (so in this case, no model changes, no graph redraws that I initiate).

I'm hoping that some of these observations might trigger an aha - that can help me understand what I might be doing wrong.

Tim

Posted: Wed Sep 12, 2007 2:46 pm
by Pep
Hi Tim,

have you tried to do :
tchart1.RemoveAllSeries

in the OnClose event ?

Posted: Wed Sep 26, 2007 1:20 pm
by 9534808
Pep wrote: have you tried to do :
tchart1.RemoveAllSeries

in the OnClose event ?
I have just tried plugging that in, and I still get the same error?

Its weird that it happens if its the only window, although I have heard reports from another Dolphin user that they have seen a similar error (and not with a single window, although my case is repeatable every time)

I have some other suggestions to try - forcing a Garbage Collect (your examples are not done in a VM based language) and trying to force a Free of the main TChart IUnknown instance.

It would be helpful if you had any other tips to help me do the dog work to locate the issue.

Tim

Posted: Wed Sep 26, 2007 3:22 pm
by 9534808
9534808 wrote: I have some other suggestions to try - forcing a Garbage Collect (your examples are not done in a VM based language) and trying to force a Free of the main TChart IUnknown instance.
I tried these suggestions and none of them seem to work.

I can get a runtime error every time if I close the TChart window on the onClose event of my application (regardless if there are other windows open or not). Obviously this is worse than before so I have rolled that change back.

Interestingly if I close my application by right clicking on the taskbar and choosing close - I don't get the runtime error. (Is it becase the taskbar has focus at this point?). Using Alt-F4 does give the error.

It really seems like there is some issue with what gets focus when the application closes - and TChart seems to play some role in this.

I'm really stumped - Active-X seemed like a neat solution but all the voodoo that goes on leaves me in the dark :(

Posted: Mon Oct 01, 2007 2:52 pm
by Pep
Hi Tim,

I'm sorry, we're not familiarized with Dolphin Smalltalk, but we can try with some things which could be related with this problem.
As you said, maybe the problem happens when the Chart is focused or a part still active, in that case you can do some tests adding :

TChart1.TabStop = True

just before each call to dialogs, editors, or before to close the app, for example :

Private Sub TChart1_OnDblClick()
TChart1.TabStop = True
TChart1.ShowEditor
End Sub

Posted: Tue Oct 02, 2007 9:10 am
by 9534808
Pep wrote:Hi Tim,

I'm sorry, we're not familiarized with Dolphin Smalltalk, but we can try with some things which could be related with this problem.
As you said, maybe the problem happens when the Chart is focused or a part still active, in that case you can do some tests adding :

TChart1.TabStop = True
Hello there - of course I appreciate that you can't know every programming language - however I am hoping that languages that support ActiveX are reasonably comparable so that you can offer me tips to diagnose the problem and determine if its a TChart problem (or my usage of it) or a Dolphin problem.

I am looking for TabStop both in the documentation and in the stubs that were generated by Dolphin (it processes the ActiveX control and infers all the methods) and I can't find any reference to TabStop? Is this a new feature in the the V8 control (I am using the latest V7 control)?

As a side note - I did a search on the web for that error and there were a few hits which indicated other people have had this issue with TChart - and it looked like they were using Delphi (it was in portugese so I am going by the google translator).

Tim

Posted: Tue Oct 02, 2007 1:36 pm
by 9534808
9534808 wrote:
Pep wrote:Hi Tim,
I am looking for TabStop both in the documentation and in the stubs that were generated by Dolphin (it processes the ActiveX control and infers all the methods) and I can't find any reference to TabStop?
Tim
Having thought about it over coffee I realise that all visual controls have the TabStop property - so I have tried what you have suggested and it didn't fix the problem.

HOWEVER - you might be on to something here, as I have undone all my other changes and applied your suggestion and I always seem to get the runtime error, even if I haven't opened the tchart settings dialog in my application or caused the graph to redraw (and the graphs do not have tab focus when I close my app).

If I remove your suggestion (e.g. the graph is not a tabstop and so I can't tab into it) then I only get the error if I pop open the settings dialog or cause the graph to redraw. If I just open my app and close it - no error, or open a tab that has the initial graph and close it, again no error.

In both cases - if I have another window open (e.g. notepad) I get no error.

This is slightly different to when I tried to fix it by closing any panes that had a graph in the OnClosing event - in this case I always got the error - another window open or not.

Does this provide any additional clues? Its very weird. I'd say to everyone to upgrade to Vista but the takeup of that doesn't seem very strong.

Tim

Posted: Mon Oct 08, 2007 9:03 am
by Pep
Hi Tim,

ok, we can do other tests. For example try to use the AutoRepaint property which allows to prevent the repainting and then when it's needed we can always set the property to true again.

You can check what happens if you set this property to False just before to call the dialogs (TChart1.AutoRepaint = False) and set it again to true when they are closed.

BTW, do you have VB installed on you system ? If so, could you please try to put a few lines of code just to check that this error only happens with Dolphin ? In csse you were able to reproduce it too, please send me a the sample of code.

Posted: Mon Oct 08, 2007 11:03 am
by 9534808
Pep wrote: You can check what happens if you set this property to False just before to call the dialogs (TChart1.AutoRepaint = False) and set it again to true when they are closed.
I have tried your suggestion (its a good one) - although I just turned off auto-repaint before showing settings dialog and didn't turn it back on. I confirmed it wasn't repainting by making some other model adjustments - however when I exit my application I still get the runtime error if no other windows are open (and no error if there is another window open).

Note from the above: I get the error even if I don't use the settings dialog (I just need to get the graph to update in some manner - using the settings dialog is a conveniant way to reproduce the problem).

With all of your suggestions - they don't really address the specific combination. Why would this only happen if there are no other windows open and not in all circumstances?

It sounds like some kind of race condition?

I will try and find someone with VB installed (what version do I need to test with a reasonably similar setup using the activeX). Would Delphi also be a suitable test environment (might be able to find someone with that too).

If you had any other quick ideas I can try in Dolphin - I would appreciate them as they are quick to try out.

Do you think Version8 might have changed anything in the way the control works (its a bit of work regenerating the interfaces but might be quick to test).

thanks,

Tim

Posted: Tue Oct 09, 2007 7:54 am
by 9534808
As a small aside - I happened to have a Windows 2000 image loaded, and I tried the above steps in it, and I get the same runtime error from the version of my application that has TChart included.

Posted: Thu Oct 11, 2007 6:58 am
by Pep
Hi Tim,
I will try and find someone with VB installed (what version do I need to test with a reasonably similar setup using the activeX). Would Delphi also be a suitable test environment (might be able to find someone with that too).
Yes, if you can to prepare a simple vb or delphi would be very good to do some tests and debug it here in order to find the problem.

Another test, as you said, would be to download the latest TeeChart Pro v8 Eval and check if the same error is happeing with that version. Some fixes have been applied to it and maybe one of them could fix that problem.