#endif // Q_WS_WIN
#include <boost/bind.hpp>
+#include <boost/crc.hpp>
#include <exception>
#include <vector>
if (icon.isEmpty())
return QIcon();
- LYXERR(Debug::GUI, "Found icon: " << icon);
+ //LYXERR(Debug::GUI, "Found icon: " << icon);
QPixmap pm;
if (!pm.load(icon)) {
LYXERR0("Cannot load icon " << icon << " please verify resource system!");
#ifdef Q_WS_WIN
/// WMF Mime handler for Windows clipboard.
- // FIXME for Windows Vista and Qt4 (see http://bugzilla.lyx.org/show_bug.cgi?id=4846)
- // But this makes LyX crash on exit when LyX is compiled in release mode and if there
- // is something in the clipboard.
+ /// \warning: see comment in ~GuiApplication and in bug 4846.
QWindowsMimeMetafile wmf_mime_;
#endif
};
#ifdef Q_WS_MACX
closeAllLinkBackLinks();
#endif
+ // FIXME: Work around bug 4846 for Windows Vista and Qt4
+ // (see http://bugzilla.lyx.org/show_bug.cgi?id=4846)
+ // If the clipboard is not cleared, LyX crashes on exit when it is
+ // compiled in release mode and if there is something in the clipboard.
+ // This is related to QWindowsMimeMetafile which is apparently not
+ // properly destroyed.
+ qApp->clipboard()->clear(QClipboard::Clipboard);
delete d;
}
case LFUN_FILE_OPEN:
if (d->views_.empty()
|| (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
- createView();
- current_view_->openDocument(to_utf8(cmd.argument()));
+ string const fname = to_utf8(cmd.argument());
+ // We want the ui session to be saved per document and not per
+ // window number. The filename crc is a good enough identifier.
+ boost::crc_32_type crc;
+ crc = for_each(fname.begin(), fname.end(), crc);
+ createView(crc.checksum());
+ current_view_->openDocument(fname);
if (!current_view_->buffer())
current_view_->close();
} else
void GuiApplication::resetGui()
{
+ // Set the language defined by the user.
+ LyX::ref().setRcGuiLanguage();
+
+ // Read menus
+ if (!readUIFile(toqstr(lyxrc.ui_file)))
+ // Gives some error box here.
+ return;
+
+ // init the global menubar on Mac. This must be done after the session
+ // was recovered to know the "last files".
+ if (d->global_menubar_)
+ d->menus_.fillMenuBar(d->global_menubar_, 0, true);
+
QHash<int, GuiView *>::iterator it;
for (it = d->views_.begin(); it != d->views_.end(); ++it)
(*it)->resetDialogs();
}
-void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
+void GuiApplication::createView(int view_id)
+{
+ createView(QString(), true, view_id);
+}
+
+
+void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
+ int view_id)
{
// release the keyboard which might have been grabed by the global
// menubar on Mac to catch shortcuts even without any GuiView.
d->global_menubar_->releaseKeyboard();
// create new view
- int id = 0;
- while (d->views_.find(id) != d->views_.end())
- id++;
+ int id = view_id;
+ if (id == 0) {
+ while (d->views_.find(id) != d->views_.end())
+ id++;
+ }
+ LYXERR(Debug::GUI, "About to create new window with ID " << id);
GuiView * view = new GuiView(id);
-
- // copy the icon size from old view
- if (current_view_)
- view->setIconSize(current_view_->iconSize());
-
// register view
d->views_[id] = view;
void GuiApplication::execBatchCommands()
{
+ // Set the language defined by the user.
+ LyX::ref().setRcGuiLanguage();
+
// Read menus
if (!readUIFile(toqstr(lyxrc.ui_file)))
// Gives some error box here.
// Ensure that a file is read only once (prevents include loops)
static QStringList uifiles;
if (uifiles.contains(name)) {
- LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
- << "Is this an include loop?");
- return false;
+ if (!include) {
+ // We are reading again the top uifile so reset the safeguard:
+ uifiles.clear();
+ d->menus_.reset();
+ d->toolbars_.reset();
+ } else {
+ LYXERR(Debug::INIT, "UI file '" << name << "' has been read already. "
+ << "Is this an include loop?");
+ return false;
+ }
}
LYXERR(Debug::INIT, "About to read " << name << "...");
if (ui_path.empty()) {
LYXERR(Debug::INIT, "Could not find " << name);
- Alert::warning(_("Could not find UI defintion file"),
+ Alert::warning(_("Could not find UI definition file"),
bformat(_("Error while reading the configuration file\n%1$s.\n"
"Please check your installation."), qstring_to_ucs4(name)));
return false;