Unsolved Irregular access violation when switching active subwindow in an MDI application
-
What happens if you don't ?
-
Same thing, no difference
-
Do you get the same issue if you create a default application and use the code from the documentation as is ?
-
I modified the mdi example to read
MdiChild *MainWindow::createMdiChild() { MdiChild *child = new MdiChild; QMdiSubWindow *subWindow1 = new QMdiSubWindow; subWindow1->setWidget(child); subWindow1->setAttribute(Qt::WA_DeleteOnClose); mdiArea->addSubWindow(subWindow1); #ifndef QT_NO_CLIPBOARD connect(child, &QTextEdit::copyAvailable, cutAct, &QAction::setEnabled); connect(child, &QTextEdit::copyAvailable, copyAct, &QAction::setEnabled); #endif return child; }
i.e. to be according to the documentation. That seems to work fine.
-
@olowo726
The difference appears to be that yousubWindow1->setAttribute(Qt::WA_DeleteOnClose);
aftersubWindow1->setWidget(child);
, in your earlier one you set it before setting the child widget, does that really alter the behaviour? -
No difference (just tested)
-
@olowo726
:) As I thought! In which case, only me, but I'd want to know what is different about their example code compared to your original attempt? Maybe if you retry your original attempt it will work now?! Anyway, up to you, you can just stick with what you do have working now. -
Sorry, I formulated myself badly, regarless of the order of the statement the application crashes.
-
I've solved this now but actually I don't know exactly why.
My application have several MDI areas which the user can switch between. I had forgotten to disconnect the tile etc. menu choices from the old MDI are when the user switched MDI area. When I corrected that the crash disappeared as well indicating that the old signal connections somehow loomed. However I don't know why, I think that the signals should have been automatically disconnected when the objects were destroyed.
-
Hi
Did you verify the objects were actually destroyed?
Else that would explain why they are still connected.