move calls to Buffer::errors and Buffer::message to GUI thread

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32606 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2009-12-21 13:11:17 +00:00
parent b379a2142a
commit 8049e3f510
4 changed files with 38 additions and 7 deletions

View File

@ -350,7 +350,7 @@ Buffer::~Buffer()
if (!isClean()) {
docstring msg = _("LyX attempted to close a document that had unsaved changes!\n");
msg += emergencyWrite();
frontend::Alert::warning(_("Attempting to close changed document!"), msg);
Alert::warning(_("Attempting to close changed document!"), msg);
}
// clear references to children in macro tables

View File

@ -97,7 +97,7 @@ void GuiProgress::doClearMessages()
void GuiProgress::appendText(QString const & text)
{
view_->message(qstring_to_ucs4(text));
view_->updateMessage(text);
}

View File

@ -193,7 +193,7 @@ struct GuiView::GuiViewPrivate
stack_widget_->addWidget(bg_widget_);
stack_widget_->addWidget(splitter_);
setBackground();
progress = new GuiProgress(gv);
progress_ = new GuiProgress(gv);
}
~GuiViewPrivate()
@ -201,7 +201,7 @@ struct GuiView::GuiViewPrivate
delete splitter_;
delete bg_widget_;
delete stack_widget_;
delete progress;
delete progress_;
}
QMenu * toolBarPopup(GuiView * parent)
@ -287,7 +287,7 @@ public:
BackgroundWidget * bg_widget_;
/// view's toolbars
ToolbarMap toolbars_;
GuiProgress* progress;
ProgressInterface* progress_;
/// The main layout box.
/**
* \warning Don't Delete! The layout box is actually owned by
@ -385,6 +385,9 @@ GuiView::GuiView(int id)
connect(&d.autosave_watcher_, SIGNAL(finished()), this,
SLOT(threadFinished()));
#endif
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
}
@ -697,8 +700,15 @@ void GuiView::message(docstring const & str)
{
if (ForkedProcess::iAmAChild())
return;
// call is moved to GUI-thread by GuiProgress
d.progress_->appendMessage(toqstr(str));
}
statusBar()->showMessage(toqstr(str));
void GuiView::updateMessage(QString const & str)
{
statusBar()->showMessage(str);
d.statusbar_timer_.stop();
d.statusbar_timer_.start(3000);
}
@ -3250,10 +3260,20 @@ Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
void GuiView::showDialog(string const & name, string const & data,
Inset * inset)
{
triggerShowDialog(toqstr(name), toqstr(data), inset);
}
void GuiView::doShowDialog(QString const & qname, QString const & qdata,
Inset * inset)
{
if (d.in_show_)
return;
const string name = fromqstr(qname);
const string data = fromqstr(qdata);
d.in_show_ = true;
try {
Dialog * dialog = findOrBuild(name, false);

View File

@ -72,7 +72,12 @@ public:
BufferView const * documentBufferView() const;
void newDocument(std::string const & filename,
bool fromTemplate);
/// could be called from any thread
void message(docstring const &);
/// must be called from GUI thread
void updateMessage(QString const & str);
bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
bool dispatch(FuncRequest const & cmd);
void restartCursor();
@ -158,6 +163,7 @@ public:
Q_SIGNALS:
void closing(int);
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
public Q_SLOTS:
/// idle timeout.
@ -183,6 +189,10 @@ private Q_SLOTS:
/// For completion of autosave or exporrt threads.
void threadFinished();
/// must be called in GUI thread
void doShowDialog(QString const & qname, QString const & qdata,
Inset * inset);
private:
/// Open given child document in current buffer directory.
void openChildDocument(std::string const & filename);
@ -243,7 +253,8 @@ public:
*/
void updateDialogs();
/** \param name == "bibtex", "citation" etc; an identifier used to
/** Show dialog could be called from arbitrary threads.
\param name == "bibtex", "citation" etc; an identifier used to
launch a particular dialog.
\param data is a string representation of the Inset contents.
It is often little more than the output from Inset::write.