MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / closeEvent

Method closeEvent

src/Gui/MainWindow.cpp:1751–1808  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1749}
1750
1751void MainWindow::closeEvent(QCloseEvent* e)
1752{
1753 Application::Instance->tryClose(e);
1754 if (e->isAccepted()) {
1755 // Send close event to all non-modal dialogs
1756 QList<QDialog*> dialogs = this->findChildren<QDialog*>();
1757 // It is possible that closing a dialog internally closes further dialogs. Thus,
1758 // we have to check the pointer before.
1759 QVector<QPointer<QDialog>> dialogs_ptr;
1760 for (const auto& dialog : dialogs) {
1761 dialogs_ptr.append(dialog);
1762 }
1763 for (auto& it : dialogs_ptr) {
1764 if (!it.isNull()) {
1765 it->close();
1766 }
1767 }
1768 QList<MDIView*> mdis = this->findChildren<MDIView*>();
1769 // Force to close any remaining (passive) MDI child views
1770 for (auto& mdi : mdis) {
1771 mdi->hide();
1772 mdi->deleteLater();
1773 }
1774
1775 if (Workbench* wb = WorkbenchManager::instance()->active()) {
1776 wb->removeTaskWatcher();
1777 }
1778
1779 Q_EMIT mainWindowClosed();
1780 d->activityTimer->stop();
1781
1782 // https://forum.freecad.org/viewtopic.php?f=8&t=67748
1783 // When the session manager jumps in it can happen that the closeEvent()
1784 // function is triggered twice and for the second call the main window might be
1785 // invisible. In this case the window settings shouldn't be saved.
1786 if (isVisible()) {
1787 saveWindowSettings();
1788 }
1789
1790 delete d->assistant;
1791 d->assistant = nullptr;
1792
1793 // See createMimeDataFromSelection
1794 QVariant prop = this->property("x-documentobject-file");
1795 if (!prop.isNull()) {
1796 Base::FileInfo fi((const char*)prop.toByteArray());
1797 if (fi.exists()) {
1798 fi.deleteFile();
1799 }
1800 }
1801
1802 if (this->property("QuitOnClosed").isValid()) {
1803 QApplication::closeAllWindows();
1804 qApp->processEvents(); // flush all pending deferredDelete events
1805 qApp->quit(); // stop the event loop
1806 }
1807 }
1808}

Callers

nothing calls this directly

Calls 14

tryCloseMethod · 0.80
instanceFunction · 0.70
isVisibleFunction · 0.70
appendMethod · 0.45
isNullMethod · 0.45
closeMethod · 0.45
hideMethod · 0.45
activeMethod · 0.45
removeTaskWatcherMethod · 0.45
stopMethod · 0.45
existsMethod · 0.45
deleteFileMethod · 0.45

Tested by

no test coverage detected