diff --git a/src/gui/parafieldwidget.cpp b/src/gui/parafieldwidget.cpp index 404c1272..3896ffff 100644 --- a/src/gui/parafieldwidget.cpp +++ b/src/gui/parafieldwidget.cpp @@ -1,66 +1,73 @@ /*************************************************************************** Copyright (C) 2005-2009 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #include "parafieldwidget.h" #include "../field.h" #include using Tellico::GUI::ParaFieldWidget; ParaFieldWidget::ParaFieldWidget(Tellico::Data::FieldPtr field_, QWidget* parent_) : FieldWidget(field_, parent_) { m_textEdit = new KTextEdit(this); m_textEdit->setAcceptRichText(false); if(field_->property(QStringLiteral("spellcheck")) != QLatin1String("false")) { m_textEdit->setCheckSpellingEnabled(true); } void (KTextEdit::* textChanged)() = &KTextEdit::textChanged; connect(m_textEdit, textChanged, this, &ParaFieldWidget::checkModified); registerWidget(); } +ParaFieldWidget::~ParaFieldWidget() { + // saw a crash when closing Tellico and the KTextEdit d'tor called ~QSyntaxHighlighter() + // when ultimately signaled a valueChange for some reason, so disconnect + void (KTextEdit::* textChanged)() = &KTextEdit::textChanged; + disconnect(m_textEdit, textChanged, this, &ParaFieldWidget::checkModified); +} + QString ParaFieldWidget::text() const { QString text = m_textEdit->toPlainText(); text.replace(QLatin1Char('\n'), QLatin1String("
")); return text; } void ParaFieldWidget::setTextImpl(const QString& text_) { QRegExp rx(QLatin1String("
"), Qt::CaseInsensitive); QString s = text_; s.replace(rx, QStringLiteral("\n")); m_textEdit->setPlainText(s); } void ParaFieldWidget::clearImpl() { m_textEdit->clear(); editMultiple(false); } QWidget* ParaFieldWidget::widget() { return m_textEdit; } diff --git a/src/gui/parafieldwidget.h b/src/gui/parafieldwidget.h index 8e6526fe..1931d72c 100644 --- a/src/gui/parafieldwidget.h +++ b/src/gui/parafieldwidget.h @@ -1,61 +1,61 @@ /*************************************************************************** Copyright (C) 2005-2009 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #ifndef TELLICO_PARAFIELDWIDGET_H #define TELLICO_PARAFIELDWIDGET_H #include "fieldwidget.h" #include "../datavectors.h" class KTextEdit; namespace Tellico { namespace GUI { /** * @author Robby Stephenson */ class ParaFieldWidget : public FieldWidget { Q_OBJECT public: ParaFieldWidget(Data::FieldPtr field, QWidget* parent); - virtual ~ParaFieldWidget() {} + virtual ~ParaFieldWidget(); virtual QString text() const Q_DECL_OVERRIDE; virtual void setTextImpl(const QString& text) Q_DECL_OVERRIDE; public Q_SLOTS: virtual void clearImpl() Q_DECL_OVERRIDE; protected: virtual QWidget* widget() Q_DECL_OVERRIDE; private: KTextEdit* m_textEdit; }; } // end GUI namespace } // end namespace #endif