Fix bug #6451 (last part): Crash when interacting with buffer-dependent dialog with no buffer open.

- First, the comment for isBufferDependent is corrected. It seems that the actual use of this function differs from the comment. As the comment said, I decided to close all dialogs that were buffer dependent, but this didn't seem to be correct for the view source pan, the outliner, and find-and-replace.

- Second, the dialogs that are buffer dependent are now closed, but dockviews are not, except for the spellchecker pane, which really depends on an open buffer, but I can't test that. 

So, please test whether the spellchecker dockviewed window behaves as one expects.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34291 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-04-26 02:12:10 +00:00
parent 28b167bfff
commit f65f5be6d7
6 changed files with 13 additions and 2 deletions

View File

@ -159,10 +159,15 @@ public:
/// Enable the Controller to dispatch its data back to the LyX kernel.
virtual void dispatchParams() = 0;
/** \return true if the dialog should be updated when the
* buffer has changed.
*/
virtual bool isBufferDependent() const = 0;
/** \return true if the dialog should be shown only when
* a buffer is open.
*/
virtual bool isBufferDependent() const = 0;
virtual bool needBufferOpen() const = 0;
/** \return true if the dialog can apply data also
* for ReadOnly buffers.

View File

@ -41,6 +41,7 @@ protected:
void applyView() {}
bool initialiseParams(std::string const & /*data*/) { return true; }
void clearParams() {}
bool needBufferOpen() const { return isBufferDependent(); }
//@}
/// Any dialog that overrides this method should make sure to call it.
void closeEvent(QCloseEvent * ev)

View File

@ -55,6 +55,7 @@ public:
//@{
void applyView() {}
bool isClosing() const { return false; }
bool needBufferOpen() const { return false; }
//@}
};

View File

@ -94,6 +94,9 @@ public:
* to close or not (no point refreshing the display for example).
*/
bool isClosing() const { return is_closing_; }
///
bool needBufferOpen() const { return isBufferDependent(); }
/// Update the display of the dialog whilst it is still visible.
virtual void updateView();

View File

@ -55,6 +55,7 @@ private:
void clearParams() {}
void dispatchParams() {}
bool isBufferDependent() const { return true; }
bool needBufferOpen() const { return true; }
///}
/// check text until next misspelled/unknown word

View File

@ -3557,7 +3557,7 @@ void GuiView::updateDialogs()
for(; it != end; ++it) {
Dialog * dialog = it->second.get();
if (dialog) {
if (dialog->isBufferDependent() && !documentBufferView())
if (dialog->needBufferOpen() && !documentBufferView())
hideDialog(fromqstr(dialog->name()), 0);
else if (dialog->isVisibleView())
dialog->checkStatus();