* src/lyxfunc.C
(LyXFunc::dispatch): Move to GuiView::closeEvent the session code
for lastpos in LFUN_LYX_QUIT. Check for unsaved changes before
initiating the quit procedure in LFUN_LYX_QUIT and LFUN_WINDOW_CLOSE.
* src/frontends/qt4/GuiView.h
(class GuiView): New boolean member quitting_by_menu_.
* src/frontends/qt4/GuiView.C
(GuiView::GuiView): Initialize quitting_by_menu_.
(GuiView::close): Set to true quitting_by_menu_ before calling
the quit procedure and reset it afterwards.
(GuiView::closeEvent): Account for the close window button.
Save last positions to the session file. Remove wrongly placed
call to quitWriteAll.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16248
a592a061-630c-0410-9148-
cb99ea01b6c8
* Non-ascii filenames do not work at all and result in an assertion or garbage.
-* open lyx, create a new document, enter a few chars, quit, click cancel, lyx
- still quits.
-
* Change Tools->Preferences->User interface->User interface to something like
"kornel.default.ui"; save prefs; exit LyX; restart LyX; => crash;
in the preferences file, there is an entry \bind_file "/Something/kornel.default"
MSVC 2005 Prof., Scons)
FIXED (JSpitzm 2006-12-11)
+* open lyx, create a new document, enter a few chars, quit, click cancel, lyx
+ still quits.
+ FIXED (Enrico 2006-12-12)
+
GuiView::GuiView(int id)
- : QMainWindow(), LyXView(id), commandbuffer_(0), d(*new GuiViewPrivate)
+ : QMainWindow(), LyXView(id), commandbuffer_(0), d(*new GuiViewPrivate),
+ quitting_by_menu_(false)
{
// Qt bug? signal lastWindowClosed does not work
setAttribute(Qt::WA_QuitOnClose, false);
void GuiView::close()
{
+ quitting_by_menu_ = true;
QMainWindow::close();
+ quitting_by_menu_ = false;
}
void GuiView::closeEvent(QCloseEvent * close_event)
{
+ // we may have been called through the close window button
+ // which bypasses the LFUN machinery.
+ if (!quitting_by_menu_) {
+ if (!theBufferList().quitWriteAll()) {
+ close_event->ignore();
+ return;
+ }
+ }
+ if (view()->buffer()) {
+ // save cursor position for opened files to .lyx/session
+ LyX::ref().session().lastFilePos().save(
+ FileName(buffer()->fileName()),
+ boost::tie(view()->cursor().pit(),
+ view()->cursor().pos()));
+ }
theApp()->gui().unregisterView(id());
if (theApp()->gui().viewIds().empty())
{
// this is the place where we leave the frontend.
// it is the only point at which we start quitting.
saveGeometry();
- theBufferList().quitWriteAll();
close_event->accept();
// quit the event loop
qApp->quit();
/// command buffer
QCommandBuffer * commandbuffer_;
+ /// are we quitting by the menu?
+ bool quitting_by_menu_;
+
///
void updateFloatingGeometry();
///
break;
case LFUN_LYX_QUIT:
- // FIXME: this code needs to be transfered somewhere else
- // as lyx_view_ will most certainly be null and a same buffer
- // might be visible in more than one LyXView.
- if (lyx_view_ && lyx_view_->view()->buffer()) {
- // save cursor Position for opened files to .lyx/session
- LyX::ref().session().lastFilePos().save(FileName(lyx_view_->buffer()->fileName()),
- boost::tie(view()->cursor().pit(), view()->cursor().pos()) );
- }
-
- // save the geometry of the current view
- lyx_view_->saveGeometry();
- // quitting is triggered by the gui code (leaving the event loop)
- theApp()->gui().closeAllViews();
+ // quitting is triggered by the gui code
+ // (leaving the event loop).
+ if (theBufferList().quitWriteAll())
+ theApp()->gui().closeAllViews();
break;
case LFUN_TOC_VIEW: {
case LFUN_WINDOW_CLOSE:
BOOST_ASSERT(lyx_view_);
BOOST_ASSERT(theApp());
+ // ask the user for saving changes or cancel quit
+ if (!theBufferList().quitWriteAll())
+ break;
lyx_view_->close();
return;