Author Topic: Change Port in Class - Exception  (Read 1279 times)

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Change Port in Class - Exception
« on: September 12, 2010, 02:31:34 pm »
Hi Roman,

could you please take a look at the attached example?

Run it and press the create button ... The class is initiated. All is fine.
Click on the Change button and change the port ... All is fine.

Close the Dialog, press Change again and try to change the port.
You will get an exception. But why  ???  ???

Greetz Dominik

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Change Port in Class - Exception
« Reply #1 on: September 12, 2010, 05:05:24 pm »
Hi Roman,

this is a really strange problem for me  :-\  I added a TNrDeviceBox to Form1. just adding - no nrcomm is assigned. So the DeviceBox is useless.

Run the app and it works without an error  ???

This is confusing me.

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Change Port in Class - Exception
« Reply #2 on: September 12, 2010, 05:28:55 pm »
Hello

Yes. The following code resolves trouble in Source_NrComm_RS232 unit:

Code: [Select]
 
  ...
  TNrCommConfig(ConfigFrame).Set_Port(FPort_NrComm);
  Form.ShowModal;
  TNrCommConfig(ConfigFrame).Set_Port(nil); // <----------- new line !!!!!!!!!!!!!!!!!!!!!
  ...
Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Change Port in Class - Exception
« Reply #3 on: September 12, 2010, 05:45:51 pm »
Hi Roman,

thx for your feedback. I will try that.

Could tell me in 1-2 sentences what´s the main problem here?
Just to learn a little bit  :)

Greetz Dominik

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Change Port in Class - Exception
« Reply #4 on: September 12, 2010, 05:57:51 pm »
Hello

We use original engine for multi target notification about changes of nrComm object states. It is like delegates in .NET, but designed more early :-)
In your case, pointer to destroyed nrDeviceBox instance is still used :-(
Shortly, it is bug. We will fix it in the next release. While you can try solution above.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

  • Full Member
  • ***
  • Posts: 122
    • View Profile
Re: Change Port in Class - Exception
« Reply #5 on: September 12, 2010, 06:00:36 pm »
Hi Roman,

Quote
Shortly, it is bug. We will fix it in the next release.
Thx

Quote
While you can try solution above.
Works like a charme  :)