mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 11:40:07 +00:00
Fix crash on exit when having edited a text area
For some reason Q/KTextEdit is sending textChanged inside the destructor, so protect us from that. BUG: 393334
This commit is contained in:
parent
6a2ed4f314
commit
3cea7c9927
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "../generators/poppler/config-okular-poppler.h"
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KConfigDialog>
|
||||
#include <KParts/OpenUrlArguments>
|
||||
|
||||
|
@ -29,6 +30,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTextEdit>
|
||||
#include <QTreeView>
|
||||
#include <QUrl>
|
||||
#include <QDesktopServices>
|
||||
|
@ -108,6 +110,7 @@ class PartTest
|
|||
void testClickAnywhereAfterSelectionShouldUnselect();
|
||||
void testeRectSelectionStartingOnLinks();
|
||||
void testCheckBoxReadOnly();
|
||||
void testCrashTextEditDestroy();
|
||||
|
||||
private:
|
||||
void simulateMouseSelection(double startX, double startY, double endX, double endY, QWidget *target);
|
||||
|
@ -1399,6 +1402,18 @@ void PartTest::testCheckBoxReadOnly()
|
|||
QVERIFY( !targetDefaultRO->isReadOnly() );
|
||||
}
|
||||
|
||||
void PartTest::testCrashTextEditDestroy()
|
||||
{
|
||||
const QString testFile = QStringLiteral( KDESRCDIR "data/formSamples.pdf" );
|
||||
Okular::Part part( nullptr, nullptr, QVariantList() );
|
||||
part.openDocument( testFile );
|
||||
part.widget()->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(part.widget()));
|
||||
|
||||
part.widget()->findChild<QTextEdit*>()->setText("HOLA");
|
||||
part.actionCollection()->action(QStringLiteral("view_toggle_forms"))->trigger();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
@ -292,6 +292,7 @@ FormWidgetIface::FormWidgetIface( QWidget * w, Okular::FormField * ff )
|
|||
|
||||
FormWidgetIface::~FormWidgetIface()
|
||||
{
|
||||
m_ff = nullptr;
|
||||
}
|
||||
|
||||
Okular::NormalizedRect FormWidgetIface::rect() const
|
||||
|
@ -668,6 +669,10 @@ void TextAreaEdit::slotHandleTextChangedByUndoRedo( int pageNumber,
|
|||
|
||||
void TextAreaEdit::slotChanged()
|
||||
{
|
||||
// happens on destruction
|
||||
if (!m_ff)
|
||||
return;
|
||||
|
||||
Okular::FormFieldText *form = static_cast<Okular::FormFieldText *>(m_ff);
|
||||
QString contents = toPlainText();
|
||||
int cursorPos = textCursor().position();
|
||||
|
|
Loading…
Reference in a new issue