mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 16:42:57 +00:00
use bind, is this really better?
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35726 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cf2ac0366c
commit
a024d3aee6
@ -370,6 +370,9 @@ public:
|
|||||||
static docstring compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
|
static docstring compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
|
||||||
static docstring saveAndDestroy(Buffer const * orig, Buffer * buffer, FileName const & fname);
|
static docstring saveAndDestroy(Buffer const * orig, Buffer * buffer, FileName const & fname);
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
static docstring runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format, string const & msg);
|
||||||
|
|
||||||
// TODO syncFunc/previewFunc: use bind
|
// TODO syncFunc/previewFunc: use bind
|
||||||
bool asyncBufferProcessing(string const & argument,
|
bool asyncBufferProcessing(string const & argument,
|
||||||
Buffer const * used_buffer,
|
Buffer const * used_buffer,
|
||||||
@ -2815,45 +2818,37 @@ bool GuiView::goToFileRow(string const & argument)
|
|||||||
|
|
||||||
|
|
||||||
#if (QT_VERSION >= 0x040400)
|
#if (QT_VERSION >= 0x040400)
|
||||||
docstring GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
template<class T>
|
||||||
|
docstring GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * buffer, string const & format, string const & msg)
|
||||||
{
|
{
|
||||||
bool const update_unincluded =
|
bool const update_unincluded =
|
||||||
buffer->params().maintain_unincluded_children
|
buffer->params().maintain_unincluded_children
|
||||||
&& !buffer->params().getIncludedChildren().empty();
|
&& !buffer->params().getIncludedChildren().empty();
|
||||||
bool const success = buffer->doExport(format, true, update_unincluded);
|
bool const success = func(format, update_unincluded);
|
||||||
delete buffer;
|
delete buffer;
|
||||||
busyBuffers.remove(orig);
|
busyBuffers.remove(orig);
|
||||||
return success
|
return success
|
||||||
? bformat(_("Successful compilation to format: %1$s"), from_utf8(format))
|
? bformat(_("Successful " + msg + " to format: %1$s"), from_utf8(format))
|
||||||
: bformat(_("Error compiling format: %1$s"), from_utf8(format));
|
: bformat(_("Error " + msg + " format: %1$s"), from_utf8(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docstring GuiView::GuiViewPrivate::compileAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
||||||
|
{
|
||||||
|
bool (Buffer::* mem_func)(std::string const &, bool, bool) const = &Buffer::doExport;
|
||||||
|
return runAndDestroy(bind(mem_func, buffer, _1, true, _2), orig, buffer, format, "export");
|
||||||
|
}
|
||||||
|
|
||||||
docstring GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
docstring GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
||||||
{
|
{
|
||||||
bool const update_unincluded =
|
bool (Buffer::* mem_func)(std::string const &, bool, bool) const = &Buffer::doExport;
|
||||||
buffer->params().maintain_unincluded_children
|
return runAndDestroy(bind(mem_func, buffer, _1, false, _2), orig, buffer, format, "export");
|
||||||
&& !buffer->params().getIncludedChildren().empty();
|
|
||||||
bool const success = buffer->doExport(format, false, update_unincluded);
|
|
||||||
delete buffer;
|
|
||||||
busyBuffers.remove(orig);
|
|
||||||
return success
|
|
||||||
? bformat(_("Successful export to format: %1$s"), from_utf8(format))
|
|
||||||
: bformat(_("Error exporting to format: %1$s"), from_utf8(format));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
docstring GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
docstring GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
||||||
{
|
{
|
||||||
bool const update_unincluded =
|
bool(Buffer::* mem_func)(std::string const &, bool) const = &Buffer::preview;
|
||||||
buffer->params().maintain_unincluded_children
|
return runAndDestroy(bind(mem_func, buffer, _1, _2), orig, buffer, format, "preview");
|
||||||
&& !buffer->params().getIncludedChildren().empty();
|
|
||||||
bool const success = buffer->preview(format, update_unincluded);
|
|
||||||
delete buffer;
|
|
||||||
busyBuffers.remove(orig);
|
|
||||||
return success
|
|
||||||
? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
|
|
||||||
: bformat(_("Error previewing format: %1$s"), from_utf8(format));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user