diff --git a/part.cpp b/part.cpp index f211f8061..e8789966e 100644 --- a/part.cpp +++ b/part.cpp @@ -1033,7 +1033,7 @@ void Part::setWindowTitleFromDocument() emit setWindowCaption( title ); } -void Part::slotGeneratorPreferences( ) +KConfigDialog * Part::slotGeneratorPreferences( ) { // Create dialog KConfigDialog * dialog = new KConfigDialog( m_pageView, "generator_prefs", Okular::Settings::self() ); @@ -1053,6 +1053,8 @@ void Part::slotGeneratorPreferences( ) // Show it dialog->setWindowModality( Qt::ApplicationModal ); dialog->show(); + + return dialog; } diff --git a/part.h b/part.h index e8f2107b6..4b3aafdb6 100644 --- a/part.h +++ b/part.h @@ -37,6 +37,7 @@ class QPrinter; class QMenu; class KUrl; +class KConfigDialog; class KConfigGroup; class KDirWatch; class KToggleAction; @@ -221,6 +222,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc void slotFileDirty( const QString& ); void slotDoFileDirty(); void psTransformEnded(int, QProcess::ExitStatus); + KConfigDialog * slotGeneratorPreferences(); private: void setupViewerActions(); @@ -332,7 +334,6 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc FileKeeper *m_keeper; private slots: - void slotGeneratorPreferences(); void slotAnnotationPreferences(); void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled); }; diff --git a/tests/parttest.cpp b/tests/parttest.cpp index b88f88835..f6db40bad 100644 --- a/tests/parttest.cpp +++ b/tests/parttest.cpp @@ -12,6 +12,7 @@ #include "../part.h" #include "../ui/toc.h" +#include #include #include @@ -29,6 +30,7 @@ class PartTest void testTOCReload(); void testFowardPDF(); void testFowardPDF_data(); + void testGeneratorPreferences(); }; void PartTest::testReload() @@ -93,6 +95,24 @@ void PartTest::testFowardPDF_data() QTest::newRow("utf8") << QString(KGlobal::dirs()->resourceDirs("tmp")[0] + QString::fromUtf8("ßðđđŋßðđŋ")); } +void PartTest::testGeneratorPreferences() +{ + KConfigDialog * dialog; + QVariantList dummyArgs; + Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent()); + + // Test that we don't crash while opening the dialog + dialog = part.slotGeneratorPreferences(); + qApp->processEvents(); + delete dialog; // closes the dialog and recursively destroys all widgets + + // Test that we don't crash while opening a new instance of the dialog + // This catches attempts to reuse widgets that have been destroyed + dialog = part.slotGeneratorPreferences(); + qApp->processEvents(); + delete dialog; +} + } int main(int argc, char *argv[])