commit 7900e9957c7ac608d1b8f72f629a3592e33928a6
Author: Scott Kostyshak <[email protected]>
Date: Sun Apr 8 17:35:09 2018 -0400
Refactor code showing error dialogs
This commit follows 8d2b121e and is not expected to change
functionality (e.g., I confirmed that the cases of #7330 and #11106
are still fixed). The advantages of this refactoring are the
following:
- Remove some preprocessor directives:
processingThreadFinished() is only called in the case that
EXPORT_in_THREAD is 1, so by moving some code up in the call list,
the directives are not needed.
- If errors() is called when there is no error, there will not be unexpected
behavior (e.g., as was the case before 8d2b121e).
Note that errors() is still only called by the code touched by this commit
if there is an error, but that is for efficiency and readability.
- The "from_master" argument now has a constant meaning. Before, it
could be the case that "from_master" was set to false but that the
master's error dialog was shown.
---
src/frontends/qt4/GuiView.cpp | 25 ++++++++++++-------------
src/frontends/qt4/GuiView.h | 5 ++---
2 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index b63f1c7..5cb6eea 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -725,9 +725,18 @@ void GuiView::processingThreadFinished()
errors("Export");
return;
}
- if (status != Buffer::ExportSuccess && status != Buffer::PreviewSuccess
&&
- status != Buffer::ExportCancel) {
- errors(d.last_export_format);
+
+ bool const error = (status != Buffer::ExportSuccess &&
+ status != Buffer::PreviewSuccess &&
+ status != Buffer::ExportCancel);
+ if (error) {
+ ErrorList & el = bv->buffer().errorList(d.last_export_format);
+ // at this point, we do not know if buffer-view or
+ // master-buffer-view was called. If there was an export error,
+ // and the current buffer's error log is empty, we guess that
+ // it must be master-buffer-view that was called so we set
+ // from_master=true.
+ errors(d.last_export_format, el.empty());
}
}
@@ -1690,19 +1699,9 @@ void GuiView::errors(string const & error_type, bool
from_master)
if (!bv)
return;
-#if EXPORT_in_THREAD
- // We are called with from_master == false by default, so we
- // have to figure out whether that is the case or not.
- ErrorList & el = bv->buffer().errorList(error_type);
- if (el.empty()) {
- el = bv->buffer().masterBuffer()->errorList(error_type);
- from_master = true;
- }
-#else
ErrorList const & el = from_master ?
bv->buffer().masterBuffer()->errorList(error_type) :
bv->buffer().errorList(error_type);
-#endif
if (el.empty())
return;
diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h
index 3ca4641..2d0ad00 100644
--- a/src/frontends/qt4/GuiView.h
+++ b/src/frontends/qt4/GuiView.h
@@ -166,9 +166,8 @@ public:
/// \name GuiBufferDelegate.
//@{
void resetAutosaveTimers();
- // shows an error list (possibly master's)
- // even if from_master is false, might show master's error list.
- // this function should only be called if there was an error (#11106).
+ // shows an error list
+ // if from_master is true, show master's error list
void errors(std::string const &, bool from_master = false);
void structureChanged();
void updateTocItem(std::string const &, DocIterator const &);