|
|
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Random problems with destructors in GUI classes
Random problems with destructors in GUI classes [message #49421] |
Thu, 08 February 2018 10:11  |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
I have random problems with GUI controls. Sometimes with DEBUG or RELEASE, when a control is destructed an EXCEPTION_ACCESS_VIOLATION exception raises. This happens in ScatterCtrl.
For example, function ScatterCtrl::DoShowEditDlg() calls PropertiesDlg(*this, itab).Run(true) opening a dialog.
Sometimes, when this dialog is closed, this errror raises. The function call stack represets basically destructors:

It is like there is a problem in the destructors order, so that in this case, when ColorPusher destructor is called, parent controls has been already destructed.
I have seen that many or maybe all GUI controls have virtual destructors. Maybe it has no sense but, should GUI user controls destructors have to be also virtual?
Best regards
Iñaki
[Updated on: Thu, 08 February 2018 10:14] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Random problems with destructors in GUI classes [message #49433 is a reply to message #49421] |
Fri, 09 February 2018 13:48   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
koldo wrote on Thu, 08 February 2018 10:11Hello all
I have random problems with GUI controls. Sometimes with DEBUG or RELEASE, when a control is destructed an EXCEPTION_ACCESS_VIOLATION exception raises. This happens in ScatterCtrl.
For example, function ScatterCtrl::DoShowEditDlg() calls PropertiesDlg(*this, itab).Run(true) opening a dialog.
Sometimes, when this dialog is closed, this errror raises. The function call stack represets basically destructors:

It is like there is a problem in the destructors order, so that in this case, when ColorPusher destructor is called, parent controls has been already destructed.
I have seen that many or maybe all GUI controls have virtual destructors. Maybe it has no sense but, should GUI user controls destructors have to be also virtual?
With very little info you have provided I would actually think that the problem here is properties dialog is already deleted when the constructor is invoked - but that is just the first thing I would check.
I have tried to identify the problem in trunk, but all seems OK there. Is this trunk code or some new development?
|
|
|
Re: Random problems with destructors in GUI classes [message #49443 is a reply to message #49433] |
Sat, 10 February 2018 23:53   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
I did not know that 'virtuality' of destructor is inherited. In fact high level U++ GUI classes like ArrayCtrl have empty virtual destructors.
Now all code is uploaded.
Virtualizing all destructors has not solved the issue.
It is like some destructor supposes that parent control already has not been closed.
Two samples:

Best regards
Iñaki
[Updated on: Sun, 11 February 2018 00:10] Report message to a moderator
|
|
|
|
|
Re: Random problems with destructors in GUI classes [message #49446 is a reply to message #49445] |
Sun, 11 February 2018 09:27   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
mirek wrote on Sun, 11 February 2018 08:33
void PropertiesDlg::OnClose()
{
measures.Change();
RejectBreak(IDOK);
Close(); Close();
}
It should not be a reason for these problems, but Break should be enough here. Why do you call Close twice after that?
Mirek
It was necessary in the past. Now is not. I have just deleted it.
Best regards
Iñaki
[Updated on: Sun, 11 February 2018 23:05] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 19:16:21 CEST 2025
Total time taken to generate the page: 0.01086 seconds
|
|
|