From 9312182085196352853d6c434ae5854e2cb6354c Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sat, 27 Sep 2014 01:56:38 +0200 Subject: [PATCH] Fix latex render in annotations We need disconnect(textEdit, SIGNAL(cursorPositionChanged()), this,SLOT(slotsaveWindowText())); and it's counterpart, otherwise when inserting the image, the cursor pos changes, slotsaveWindowText is called, the content is passed by a toPlainText and set again and kaboom the content is lost Also a few extra const BUGS: 335476 FIXED-IN: 4.14.2 --- ui/annotwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/annotwindow.cpp b/ui/annotwindow.cpp index a9363e717..6677c6fc9 100644 --- a/ui/annotwindow.cpp +++ b/ui/annotwindow.cpp @@ -327,8 +327,8 @@ void AnnotWindow::slotOptionBtn() void AnnotWindow::slotsaveWindowText() { - QString contents = textEdit->toPlainText(); - int cursorPos = textEdit->textCursor().position(); + const QString contents = textEdit->toPlainText(); + const int cursorPos = textEdit->textCursor().position(); if (contents != m_annot->contents()) { m_document->editPageAnnotationContents( m_page, m_annot, contents, cursorPos, m_prevCursorPos, m_prevAnchorPos); @@ -344,6 +344,7 @@ void AnnotWindow::renderLatex( bool render ) { textEdit->setReadOnly( true ); disconnect(textEdit, SIGNAL(textChanged()), this,SLOT(slotsaveWindowText())); + disconnect(textEdit, SIGNAL(cursorPositionChanged()), this,SLOT(slotsaveWindowText())); textEdit->setAcceptRichText( true ); QString contents = m_annot->contents(); contents = Qt::convertFromPlainText( contents ); @@ -384,6 +385,7 @@ void AnnotWindow::renderLatex( bool render ) textEdit->setAcceptRichText( false ); textEdit->setPlainText( m_annot->contents() ); connect(textEdit, SIGNAL(textChanged()), this,SLOT(slotsaveWindowText())); + connect(textEdit, SIGNAL(cursorPositionChanged()), this,SLOT(slotsaveWindowText())); textEdit->setReadOnly( false ); } }