From ede1b97b4658156b8287f150e46f46a38fc44dae Mon Sep 17 00:00:00 2001 From: cc9cii Date: Wed, 19 Nov 2014 18:10:29 +1000 Subject: [PATCH 1/3] Check the type of universal id before getting its id. Should resolve bug #2137 --- apps/opencs/view/doc/view.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 8b5efbea7..8dd8494dc 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -474,8 +474,13 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin { foreach(SubView *sb, mSubViews) { - if((isReferenceable && (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()) == CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, sb->getUniversalId().getId()))) - || (!isReferenceable && (id == sb->getUniversalId()))) + bool isSubViewReferenceable = + sb->getUniversalId().getType() == CSMWorld::UniversalId::Type_Referenceable; + + if((isReferenceable && isSubViewReferenceable && + id.getId() == sb->getUniversalId().getId()) + || + (!isReferenceable && id == sb->getUniversalId())) { sb->setFocus(Qt::OtherFocusReason); // FIXME: focus not quite working return; From 911839bb91b3e2dfa7e675493b47784abd9877b5 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 21 Nov 2014 06:48:42 +1100 Subject: [PATCH 2/3] Simplify detecting whether a universal id represents a referenceable type. --- apps/opencs/view/doc/view.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 8dd8494dc..d64d36aec 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -464,8 +464,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin { CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); - const std::vector referenceables(CSMWorld::UniversalId::listReferenceableTypes()); - bool isReferenceable = std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end(); + bool isReferenceable = id.getClass() == CSMWorld::UniversalId::Class_RefRecord; // User setting to reuse sub views (on a per top level view basis) bool reuse = @@ -477,12 +476,11 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin bool isSubViewReferenceable = sb->getUniversalId().getType() == CSMWorld::UniversalId::Type_Referenceable; - if((isReferenceable && isSubViewReferenceable && - id.getId() == sb->getUniversalId().getId()) + if((isReferenceable && isSubViewReferenceable && id.getId() == sb->getUniversalId().getId()) || (!isReferenceable && id == sb->getUniversalId())) { - sb->setFocus(Qt::OtherFocusReason); // FIXME: focus not quite working + sb->setFocus(); return; } } @@ -502,7 +500,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin } SubView *view = NULL; - if(std::find(referenceables.begin(), referenceables.end(), id.getType()) != referenceables.end()) + if(isReferenceable) { view = mSubViewFactory.makeSubView (CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()), *mDocument); } From 31fdf4961676712bb9af4bc7d905248931aba6a2 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 22 Nov 2014 06:59:23 +1100 Subject: [PATCH 3/3] Use Qt exit function rather than system one. --- apps/opencs/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 591667ebb..bef83b8ac 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -379,5 +379,5 @@ void CS::Editor::documentAdded (CSMDoc::Document *document) void CS::Editor::lastDocumentDeleted() { - exit (0); + QApplication::quit(); }