Abdelrazak Younes wrote:
Bennett Helm wrote:
On Feb 26, 2008, at 10:23 AM, Abdelrazak Younes wrote:
However:
1. Nothing has change with respect to my command-sequence: when
multiple files are open, each in their own window, they all get closed.
I guess this is a bug in the Mac plaftorm. Please try without your
command-sequence, just with a simple window close. There is no cross
button in the top-right corner on Mac? just "window-close" should
suffice if not.
It works properly if I click on the red circle on the top left corner
(the Mac equivalent of the cross button). But entering window-close in
the command buffer (on its own -- not in a command-sequence) results
in all documents closing.
I see. Then it's a bug.
Please update and try again.
Abdel.
Author: younes
Date: Wed Feb 27 11:35:28 2008
New Revision: 23271
URL: http://www.lyx.org/trac/changeset/23271
Log:
Cleanup app quitting and window closing now that there is a clean
separation between the frontend and the core.
Modified:
lyx-devel/trunk/src/frontends/LyXView.h
lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp
lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
lyx-devel/trunk/src/frontends/qt4/GuiView.h
Modified: lyx-devel/trunk/src/frontends/LyXView.h
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/LyXView.h?rev=23271
==============================================================================
--- lyx-devel/trunk/src/frontends/LyXView.h (original)
+++ lyx-devel/trunk/src/frontends/LyXView.h Wed Feb 27 11:35:28 2008
@@ -49,8 +49,6 @@
virtual ~LyXView() {}
///
virtual int id() const = 0;
- ///
- virtual void close() = 0;
/// show busy cursor
virtual void setBusy(bool) = 0;
Modified: lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp?rev=23271
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiApplication.cpp Wed Feb 27
11:35:28 2008
@@ -251,9 +251,6 @@
// update bookmark pit of the current buffer before window close
for (size_t i = 0; i < LyX::ref().session().bookmarks().size();
++i)
theLyXFunc().gotoBookmark(i+1, false, false);
- // ask the user for saving changes or cancel quit
- if (!current_view_->quitWriteAll())
- break;
current_view_->close();
break;
@@ -261,8 +258,8 @@
// quitting is triggered by the gui code
// (leaving the event loop).
current_view_->message(from_utf8(N_("Exiting.")));
- if (current_view_->quitWriteAll())
- closeAllViews();
+ if (closeAllViews())
+ quit();
break;
case LFUN_SCREEN_FONT_UPDATE: {
@@ -548,8 +545,9 @@
/// The default implementation sends a close event to all
/// visible top level widgets when session managment allows
/// interaction.
- /// We are changing that to write all unsaved buffers...
- if (sm.allowsInteraction() && !current_view_->quitWriteAll())
+ /// We are changing that to close all wiew one by one.
+ /// FIXME: verify if the default implementation is enough now.
+ if (sm.allowsInteraction() && !closeAllViews())
sm.cancel();
}
@@ -581,20 +579,14 @@
bool GuiApplication::closeAllViews()
{
updateIds(views_, view_ids_);
- if (views_.empty()) {
- // quit in CloseEvent will not be triggert
- qApp->quit();
+ if (views_.empty())
return true;
- }
map<int, GuiView*> const cmap = views_;
map<int, GuiView*>::const_iterator it;
for (it = cmap.begin(); it != cmap.end(); ++it) {
- // TODO: return false when close event was ignored
- // e.g. quitWriteAll()->'Cancel'
- // maybe we need something like 'bool closeView()'
- it->second->close();
- // unregisterd by the CloseEvent
+ if (!it->second->close())
+ return false;
}
views_.clear();
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiView.cpp?rev=23271
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Wed Feb 27 11:35:28 2008
@@ -145,8 +145,8 @@
struct GuiView::GuiViewPrivate
{
GuiViewPrivate()
- : current_work_area_(0), layout_(0),
- quitting_by_menu_(false), autosave_timeout_(5000),
in_show_(false)
+ : current_work_area_(0), layout_(0), autosave_timeout_(5000),
+ in_show_(false)
{
// hardcode here the platform specific icon size
smallIconSize = 14; // scaling problems
@@ -263,8 +263,6 @@
unsigned int bigIconSize;
///
QTimer statusbar_timer_;
- /// are we quitting by the menu?
- bool quitting_by_menu_;
/// auto-saving of buffers
Timeout autosave_timeout_;
/// flag against a race condition due to multiclicks, see bug #1119
@@ -336,20 +334,6 @@
}
-void GuiView::close()
-{
- d.quitting_by_menu_ = true;
- d.current_work_area_ = 0;
- for (int i = 0; i != d.splitter_->count(); ++i) {
- TabWorkArea * twa = d.tabWorkArea(i);
- if (twa)
- twa->closeAll();
- }
- QMainWindow::close();
- d.quitting_by_menu_ = false;
-}
-
-
void GuiView::setFocus()
{
if (d.current_work_area_)
@@ -381,15 +365,6 @@
void GuiView::closeEvent(QCloseEvent * close_event)
{
- // we may have been called through the close window button
- // which bypasses the LFUN machinery.
- if (!d.quitting_by_menu_ && guiApp->viewCount() == 1) {
- if (!quitWriteAll()) {
- close_event->ignore();
- return;
- }
- }
-
while (Buffer * b = buffer()) {
if (b->parent()) {
// This is a child document, just close the tab after
saving
@@ -406,7 +381,7 @@
for (int i = 0; i != ids.size(); ++i) {
if (id_ == ids[i])
continue;
- if (GuiWorkArea * wa =
guiApp->view(ids[i]).workArea(*b)) {
+ if (guiApp->view(ids[i]).workArea(*b)) {
// FIXME 1: should we put an alert box here
that the buffer
// is viewed elsewhere?
// FIXME 2: should we try to save this buffer
in any case?
@@ -1627,6 +1602,10 @@
else
file = buf.fileName().displayName(30);
+ // Bring this window to top before asking questions.
+ raise();
+ activateWindow();
+
docstring const text = bformat(_("The document %1$s has unsaved
changes."
"\n\nDo you want to save the document or discard the
changes?"), file);
int const ret = Alert::prompt(_("Save changed document?"),
@@ -1654,17 +1633,6 @@
LyX::ref().session().lastOpened().add(buf.fileName());
theBufferList().release(&buf);
- return true;
-}
-
-
-bool GuiView::quitWriteAll()
-{
- while (!theBufferList().empty()) {
- Buffer * b = theBufferList().first();
- if (!closeBuffer(*b))
- return false;
- }
return true;
}
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.h
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiView.h?rev=23271
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.h (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.h Wed Feb 27 11:35:28 2008
@@ -62,7 +62,6 @@
///
int id() const { return id_; }
- void close();
void setFocus();
void setBusy(bool);
/// returns true if this view has the focus.
@@ -99,8 +98,6 @@
void importDocument(std::string const &);
///
void newDocument(std::string const & filename, bool fromTemplate);
- /// write all buffers, asking the user, returns false if cancelled
- bool quitWriteAll();
/// GuiBufferDelegate.
///@{