mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Refactor code showing error dialogs
This commit follows8d2b121e
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 before8d2b121e
). 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.
This commit is contained in:
parent
d10317978a
commit
7900e9957c
@ -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;
|
||||
|
@ -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 &);
|
||||
|
Loading…
Reference in New Issue
Block a user