Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

ComponentWorks 2 CWGraph crashes under Windows NT/2K and Borland C++ Builder 5

When I use ComponentWorks 2 with Borland C++ Builder 5 on Windows NT or Windows 2000, strange things are happening. I can build my application and it runs fine under the debugger. When I try to launch it from the Windows NT explorer, it is flakey, and will quickly crash in various ways. Alerts complain about access violations, invalid variant operations, C++ exceptions, or my favorite, the application just quits with no error message. The application is very stable when run in the debugger, and is also very stable when run under Windows 98.

In my application, I commented out just two lines, and it is very stable under NT, even when not in the debugger. These two lines are c
alls to CWGraph::PlotXY() and CWPlot::PlotXY(). Of course, with these lines disabled the application is not very interesting (just blank black boxes) but at least it doesn't crash.

I even downloaded the sample code at http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/0d7fe3f073411711862568c500731847/$FILE/BCB4Graph.zip

This did not compile, it had many errors everywhere a Variant was passed in as an argument to a ComponentWorks function. The errors complain about an abiguity between TVariant::TVariantT(Variant) and Variant::operator TVariant(). By manually casting the Variants to TVariants I can get the application to compile, but it shows the same behavior: Very stable in the debugger, but eventually crashes when not in the debugger.

I'm stumped. What do I try next?
0 Kudos
Message 1 of 4
(3,630 Views)
Have you checked out KB article 0XC7UQ1J?
Go to www.ni.com/support and search for that key - the document is entitled "Using ComponentWorks in Borland C++ Builder".
It outlines common issues for developers trying to integrate CW++ into Borland, including how to pass variants and handle CWGraph objects.

good luck-
ben schulte
national instruments
0 Kudos
Message 2 of 4
(3,630 Views)
Ben, Thank you for your answer. I'm not new to Component works (used it for a couple of years now), and I've seen that document years ago (it is almost 4 years old.) I'm way past the basics that are covered in that document.

I won't repeat all the details here, but please go back and re-read the original posting. I have a large complex application that works well and is rock solid when running under Windows 98. However, when run under Windows NT, it is unstable and will crash within 30 seconds of use. The really wierd part is that it is also rock solid when run in the debugger under Windows NT, a fact which makes it really difficult to figure out just where and why it's crashing.

The interesting thing is that when I comment out my two calls to PlotXY, the application is once again rock solid.

When it crashes, it always appears to be doing something with Variants (like making an assignment) and not in the PlotXY call. This makes me think that there is some interaction or corruption occuring in PlotXY, which causes a crash sometime later when accessing a Variant variable. But why only under NT, but not in the debugger? I'm so confused...

I'm also confused why the sample code I just downloaded a couple of days ago dosen't compile, code which says it is written specifically for the Borland C++ Builder compiler. Am I doing something wrong, or could I have a problem with my configuration?

The gist of the compilation problems is that the Borland-generated wrapper class methods use TVariant parameters. The KB article you reference, and the sample code (as well as my own code) use Variant (note that difference from TVariant). Variant has the required methods (such as PutElement and GetElement) that are lacking in TVariant, or I would be tempted to just use TVariants everywhere. The problem is when I try to use a Variant variable for those TVariant arguments, I get compilation errors complaining about abiguities (see original posting.) So I am resorting to type conversions, thereby working around these errors, (successfully I thought, based on past experience) but now with these NT problems I'm wondering if I'm doing something wrong.

I still don't understand how the sample code can be compiled, given these problems. Is there something wrong with my compiler setup? If so, it's been wrong through three versions of Borland and numerous updates, and with six different development computers running various OS's.

My application is large and complex, and is therefore a poor example to illustrate this issue. However, the sample code I had referred to is a good example. It doesn't compile (at least not for me) even though it does everthing mentioned in the KB article. When I edit it so it does compile, it shows the same problems I am having: solid under '98, flaky under 'NT, but solid under 'NT and the debugger.

Can you, or somebody else, compile that sample code under C++ Builder, and successfully run it under Windows NT? Once running, click on either or both of the plot buttons. In my case, after anwhere from 10 to 30 clicks later it will start to be flakey, and then crash.

If anybody can get it to compile, and it's stable, please let me know how you did it. If you had to edit the code, let me see what you did.

Please forgive the extended rambling. I'm getting desperate here.

-- Adam
0 Kudos
Message 3 of 4
(3,630 Views)
"avm" ???????/???????? ? ???????? ?????????:
news:506500000008000000D7170000-984882144000@quiq.com...
> When I use ComponentWorks 2 with Borland C++ Builder 5 on Windows NT
> or Windows 2000, strange things are happening. I can build my
> application and it runs fine under the debugger. When I try to launch
> it from the Windows NT explorer, it is flakey, and will quickly crash
> in various ways. Alerts complain about access violations, invalid
> variant operations, C++ exceptions, or my favorite, the application
> just quits with no error message. The application is very stable when
> run in the debugger, and is also very stable when run under Windows
> 98.

How about source code or code where You using CWGraph object?

http://zone.ni.com/devzone/explprog
.nsf/6c163603265406328625682a006ed37d/0d7
fe3f073411711862568c500731847/$FILE/BCB4Graph.zip
>
> This did not compile, it had many errors everywhere a Variant was
> passed in as an argument to a ComponentWorks function. The errors
> complain about an abiguity between TVariant::TVariantT(Variant) and
> Variant::operator TVariant(). By manually casting the Variants to
> TVariants I can get the application to compile, but it shows the same
> behavior: Very stable in the debugger, but eventually crashes when not
> in the debugger.

It's must be work properly, if You make your code like this:

Variant XData(OPENARRAY(int,(0,40)),varDouble);
Variant YData(OPENARRAY(int,(0,40)),varDouble);
int i = 40;
float data;
for(i=0; i<=40; i++)
{
data = (float)i;
XData.PutElement(data,i);
data = sin(i/5.0);
YData.PutElement(data,i);
}
CWGraph1->PlotXvsY((VARIANT)XData,(VARIANT)YData,TVariant(true));

> I'm stumped. What do I try next?
0 Kudos
Message 4 of 4
(3,630 Views)