forked from mirror/openmw-tes3mp
Fix logic errors.
This commit is contained in:
parent
84f5784575
commit
4471fe771e
3 changed files with 40 additions and 12 deletions
|
@ -27,7 +27,7 @@ void CSVDoc::View::closeEvent (QCloseEvent *event)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// closeRequest() returns true if last document
|
// closeRequest() returns true if last document
|
||||||
mViewManager.removeDocument(mDocument);
|
mViewManager.removeDocAndView(mDocument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ bool CSVDoc::ViewManager::closeRequest (View *view)
|
||||||
{
|
{
|
||||||
std::vector<View *>::iterator iter = std::find (mViews.begin(), mViews.end(), view);
|
std::vector<View *>::iterator iter = std::find (mViews.begin(), mViews.end(), view);
|
||||||
|
|
||||||
bool continueWithClose = true;
|
bool continueWithClose = false;
|
||||||
|
|
||||||
if (iter!=mViews.end())
|
if (iter!=mViews.end())
|
||||||
{
|
{
|
||||||
|
@ -192,10 +192,22 @@ bool CSVDoc::ViewManager::closeRequest (View *view)
|
||||||
return continueWithClose;
|
return continueWithClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::ViewManager::removeDocument (CSMDoc::Document *document)
|
// NOTE: This method assumes that it is called only if the last document
|
||||||
|
void CSVDoc::ViewManager::removeDocAndView (CSMDoc::Document *document)
|
||||||
{
|
{
|
||||||
if(document)
|
for (std::vector<View *>::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
|
||||||
mDocumentManager.removeDocument(document);
|
{
|
||||||
|
// the first match should also be the only match
|
||||||
|
if((*iter)->getDocument() == document)
|
||||||
|
{
|
||||||
|
mDocumentManager.removeDocument(document);
|
||||||
|
(*iter)->deleteLater();
|
||||||
|
mViews.erase (iter);
|
||||||
|
|
||||||
|
updateIndices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVDoc::ViewManager::notifySaveOnClose (CSVDoc::View *view)
|
bool CSVDoc::ViewManager::notifySaveOnClose (CSVDoc::View *view)
|
||||||
|
@ -354,14 +366,23 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// don't bother closing views or updating indicies, but remove from mViews
|
||||||
CSMDoc::Document * document = view->getDocument();
|
CSMDoc::Document * document = view->getDocument();
|
||||||
removeDocument(document);
|
std::vector<View *> remainingViews;
|
||||||
view->setVisible(false);
|
for (std::vector<View *>::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
|
||||||
|
{
|
||||||
|
if(document == (*iter)->getDocument())
|
||||||
|
(*iter)->setVisible(false);
|
||||||
|
else
|
||||||
|
remainingViews.push_back(*iter);
|
||||||
|
}
|
||||||
|
mDocumentManager.removeDocument(document);
|
||||||
|
mViews = remainingViews;
|
||||||
|
|
||||||
// attempt to close all other documents
|
// attempt to close all other documents
|
||||||
while(!mViews.empty())
|
while(!mViews.empty())
|
||||||
{
|
{
|
||||||
// raise the window
|
// raise the window to alert the user
|
||||||
mViews.back()->activateWindow();
|
mViews.back()->activateWindow();
|
||||||
mViews.back()->raise();
|
mViews.back()->raise();
|
||||||
if (!notifySaveOnClose(mViews.back()))
|
if (!notifySaveOnClose(mViews.back()))
|
||||||
|
@ -369,9 +390,16 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document = mViews.back()->getDocument();
|
document = mViews.back()->getDocument();
|
||||||
removeDocument(document);
|
remainingViews.clear();
|
||||||
mViews.back()->setVisible(false);
|
for (std::vector<View *>::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
|
||||||
mViews.pop_back();
|
{
|
||||||
|
if(document == (*iter)->getDocument())
|
||||||
|
(*iter)->setVisible(false);
|
||||||
|
else
|
||||||
|
remainingViews.push_back(*iter);
|
||||||
|
}
|
||||||
|
mDocumentManager.removeDocument(document);
|
||||||
|
mViews = remainingViews;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace CSVDoc
|
||||||
///< Return number of views for \a document.
|
///< Return number of views for \a document.
|
||||||
|
|
||||||
bool closeRequest (View *view);
|
bool closeRequest (View *view);
|
||||||
void removeDocument (CSMDoc::Document *document);
|
void removeDocAndView (CSMDoc::Document *document);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue