mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix cancel on quit
* 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
This commit is contained in:
parent
9c62a5e332
commit
d08210e961
@ -40,9 +40,6 @@ FILE
|
||||
|
||||
* 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"
|
||||
@ -553,3 +550,7 @@ CREDITS:
|
||||
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)
|
||||
|
||||
|
@ -156,7 +156,8 @@ unsigned int GuiView::GuiViewPrivate::lastIconSize = 0;
|
||||
|
||||
|
||||
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);
|
||||
@ -186,7 +187,9 @@ GuiView::~GuiView()
|
||||
|
||||
void GuiView::close()
|
||||
{
|
||||
quitting_by_menu_ = true;
|
||||
QMainWindow::close();
|
||||
quitting_by_menu_ = false;
|
||||
}
|
||||
|
||||
|
||||
@ -240,13 +243,27 @@ void GuiView::macQuit()
|
||||
|
||||
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();
|
||||
|
@ -132,6 +132,9 @@ private:
|
||||
/// command buffer
|
||||
QCommandBuffer * commandbuffer_;
|
||||
|
||||
/// are we quitting by the menu?
|
||||
bool quitting_by_menu_;
|
||||
|
||||
///
|
||||
void updateFloatingGeometry();
|
||||
///
|
||||
|
@ -1034,19 +1034,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
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: {
|
||||
@ -1666,6 +1657,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user