mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
#7149 correct current_view_ or add checks for it for: LFUN_WINDOW_CLOSE,LFUN_SET_COLOR,LFUN_SERVER_GET_FILENAME and LFUN_BOOKMARK_GOTO
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37313 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d469e5dd8b
commit
dd2e73f365
@ -1169,10 +1169,13 @@ void GuiApplication::gotoBookmark(unsigned int idx, bool openFile,
|
|||||||
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
|
dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"));
|
||||||
|
|
||||||
// if the current buffer is not that one, switch to it.
|
// if the current buffer is not that one, switch to it.
|
||||||
BufferView * doc_bv = current_view_->documentBufferView();
|
BufferView * doc_bv = current_view_ ?
|
||||||
|
current_view_->documentBufferView() : 0;
|
||||||
if (!doc_bv || doc_bv->buffer().fileName() != tmp.filename) {
|
if (!doc_bv || doc_bv->buffer().fileName() != tmp.filename) {
|
||||||
if (switchToBuffer) {
|
if (switchToBuffer) {
|
||||||
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
dispatch(FuncRequest(LFUN_BUFFER_SWITCH, file));
|
||||||
|
if (!current_view_)
|
||||||
|
return;
|
||||||
doc_bv = current_view_->documentBufferView();
|
doc_bv = current_view_->documentBufferView();
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
@ -1295,7 +1298,10 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
// clear the last opened list, because
|
// clear the last opened list, because
|
||||||
// maybe this will end the session
|
// maybe this will end the session
|
||||||
theSession().lastOpened().clear();
|
theSession().lastOpened().clear();
|
||||||
current_view_->closeScheduled();
|
// check for valid current_view_
|
||||||
|
validateCurrentView();
|
||||||
|
if (current_view_)
|
||||||
|
current_view_->closeScheduled();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_LYX_QUIT:
|
case LFUN_LYX_QUIT:
|
||||||
@ -1418,8 +1424,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!lcolor.setColor(lyx_name, x11_name)) {
|
if (!lcolor.setColor(lyx_name, x11_name)) {
|
||||||
current_view_->message(
|
if (current_view_)
|
||||||
bformat(_("Set-color \"%1$s\" failed "
|
current_view_->message(
|
||||||
|
bformat(_("Set-color \"%1$s\" failed "
|
||||||
"- color is undefined or "
|
"- color is undefined or "
|
||||||
"may not be redefined"),
|
"may not be redefined"),
|
||||||
from_utf8(lyx_name)));
|
from_utf8(lyx_name)));
|
||||||
@ -1480,13 +1487,18 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
|
|
||||||
// --- lyxserver commands ----------------------------
|
// --- lyxserver commands ----------------------------
|
||||||
case LFUN_SERVER_GET_FILENAME: {
|
case LFUN_SERVER_GET_FILENAME: {
|
||||||
LASSERT(current_view_ && current_view_->documentBufferView(), return);
|
if (current_view_ && current_view_->documentBufferView()) {
|
||||||
docstring const fname = from_utf8(
|
docstring const fname = from_utf8(
|
||||||
current_view_->documentBufferView()->buffer().absFileName());
|
current_view_->documentBufferView()->buffer().absFileName());
|
||||||
dr.setMessage(fname);
|
dr.setMessage(fname);
|
||||||
LYXERR(Debug::INFO, "FNAME[" << fname << ']');
|
LYXERR(Debug::INFO, "FNAME[" << fname << ']');
|
||||||
|
} else {
|
||||||
|
dr.setMessage(docstring());
|
||||||
|
LYXERR(Debug::INFO, "No current file for LFUN_SERVER_GET_FILENAME");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_SERVER_NOTIFY: {
|
case LFUN_SERVER_NOTIFY: {
|
||||||
docstring const dispatch_buffer = d->keyseq.print(KeySequence::Portable);
|
docstring const dispatch_buffer = d->keyseq.print(KeySequence::Portable);
|
||||||
dr.setMessage(dispatch_buffer);
|
dr.setMessage(dispatch_buffer);
|
||||||
@ -2041,6 +2053,8 @@ void GuiApplication::restoreGuiSession()
|
|||||||
LastOpenedSection::LastOpened const & lastopened =
|
LastOpenedSection::LastOpened const & lastopened =
|
||||||
session.lastOpened().getfiles();
|
session.lastOpened().getfiles();
|
||||||
|
|
||||||
|
validateCurrentView();
|
||||||
|
|
||||||
FileName active_file;
|
FileName active_file;
|
||||||
// do not add to the lastfile list since these files are restored from
|
// do not add to the lastfile list since these files are restored from
|
||||||
// last session, and should be already there (regular files), or should
|
// last session, and should be already there (regular files), or should
|
||||||
@ -2062,7 +2076,7 @@ void GuiApplication::restoreGuiSession()
|
|||||||
|
|
||||||
// Restore last active buffer
|
// Restore last active buffer
|
||||||
Buffer * buffer = theBufferList().getBuffer(active_file);
|
Buffer * buffer = theBufferList().getBuffer(active_file);
|
||||||
if (buffer)
|
if (buffer && current_view_)
|
||||||
current_view_->setBuffer(buffer);
|
current_view_->setBuffer(buffer);
|
||||||
|
|
||||||
// clear this list to save a few bytes of RAM
|
// clear this list to save a few bytes of RAM
|
||||||
@ -2150,7 +2164,7 @@ bool GuiApplication::notify(QObject * receiver, QEvent * event)
|
|||||||
this->exit(1);
|
this->exit(1);
|
||||||
|
|
||||||
case BufferException: {
|
case BufferException: {
|
||||||
if (!current_view_->documentBufferView())
|
if (!current_view_ || !current_view_->documentBufferView())
|
||||||
return false;
|
return false;
|
||||||
Buffer * buf = ¤t_view_->documentBufferView()->buffer();
|
Buffer * buf = ¤t_view_->documentBufferView()->buffer();
|
||||||
docstring details = e.details_ + '\n';
|
docstring details = e.details_ + '\n';
|
||||||
|
Loading…
Reference in New Issue
Block a user