Avoid Qt warning re mdi window not in workspace

This commit is contained in:
wandererfan
2018-05-26 20:40:43 -04:00
parent c96d72bd67
commit a6e9eec5ad
2 changed files with 21 additions and 3 deletions

View File

@@ -28,6 +28,7 @@
# include <QAction>
# include <QMenu>
# include <QTimer>
#include <QList>
#include <QPointer>
#include <boost/signals2.hpp>
#include <boost/signals2/connection.hpp>
@@ -71,7 +72,8 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
ViewProviderPage::ViewProviderPage()
: m_mdiView(0),
m_docReady(true)
m_docReady(true),
m_pageName("")
{
sPixmap = "TechDraw_Tree_Page";
@@ -91,6 +93,7 @@ void ViewProviderPage::attach(App::DocumentObject *pcFeat)
auto feature = getDrawPage();
if (feature != nullptr) {
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
m_pageName = feature->getNameInDocument();
} else {
Base::Console().Log("VPP::attach has no Feature!\n");
}
@@ -117,12 +120,21 @@ void ViewProviderPage::show(void)
//this "hide" is only used for Visibility property toggle
//not when Page tab is closed.
//WF: is this right? same behaviour either way.
void ViewProviderPage::hide(void)
{
if (!m_mdiView.isNull()) { //m_mdiView is a QPointer
// https://forum.freecadweb.org/viewtopic.php?f=3&t=22797&p=182614#p182614
//Gui::getMainWindow()->activatePreviousWindow();
Gui::getMainWindow()->removeWindow(m_mdiView);
QList<QWidget*> wList= Gui::getMainWindow()->windows();
bool found = wList.contains(m_mdiView);
if (found) {
Gui::getMainWindow()->removeWindow(m_mdiView);
Gui::MDIView* aw = Gui::getMainWindow()->activeWindow(); //WF: this bit should be in the remove window logic, not here.
if (aw != nullptr) {
aw->showMaximized();
}
}
}
ViewProviderDocumentObject::hide();
}
@@ -203,11 +215,16 @@ bool ViewProviderPage::showMDIViewPage()
(pcObject->getDocument());
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
m_mdiView->setDocumentObject(getDrawPage()->getNameInDocument());
m_mdiView->setDocumentName(pcObject->getDocument()->getName());
m_mdiView->setWindowTitle(tabTitle + QString::fromLatin1("[*]"));
m_mdiView->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
m_mdiView->updateDrawing();
Gui::getMainWindow()->addWindow(m_mdiView);
m_mdiView->viewAll();
m_mdiView->viewAll(); //this is empty function
m_mdiView->showMaximized();
} else {
m_mdiView->updateDrawing();
m_mdiView->redrawAllViews();

View File

@@ -87,6 +87,7 @@ protected:
private:
QPointer<MDIViewPage> m_mdiView;
bool m_docReady;
std::string m_pageName;
};
} // namespace TechDrawGui