Crash on exit after accessing TextBox->TextScale

Somewhat strange problem here...

 

ST2 MP12 x64, Win7 x64, VC++2010.

 

I am accessing the TextScale property of a text box, like this:

 

double textScale = pTextBox->TextScale;
This line of code, as you would expect, produces no errors at runtime, and correctly stores the value. I can also write to this property without any problems. The weird part comes when I exit Solid Edge. All SE pointers created in my code are set to NULL when finished with - everything is as it should be. But that line causes SE to crash on exit - ANNOT.DEX triggers an access violation. On a machine with a fairly old graphics driver this error does not occur. I *can* leave the feature this line is required by out of this version of my addin if necessary for the time being, but I was curious to see if anyone else had encountered this problem and had a way around it? Cheers.

 

Posted by: Paul Dobson
Post date: 5/24/2012 8:05:47 AM

1 REPLY

Re: Crash on exit after accessing TextBox->TextScale

What do you do with "pTextBox" after that line of code? Is it released? You don't want to release pointers after a document is closed and you definitely don't want to release pointers in your DLL unload code. For instance, never declare a (I am assuming c++) smart pointer as static in your DLL as the pointer won't get a call to Release until your DLL is unloaded. And the order DLLs unload can mean the object you are trying to release may be in a DLL that is unloaded - kaboom!

 

Posted by: R.D. Holland
Post date: 6/26/2012 3:38:33 PM