Test that we don't crash if we open the Configure backends dialog twice

This would have caught the issue fixed in 3dd3a000db
remotes/origin/epub-qtextdoc
Fabio D'Urso 13 years ago
parent 3c7d61fc24
commit 889c942909
  1. 4
      part.cpp
  2. 3
      part.h
  3. 20
      tests/parttest.cpp

@ -1033,7 +1033,7 @@ void Part::setWindowTitleFromDocument()
emit setWindowCaption( title ); emit setWindowCaption( title );
} }
void Part::slotGeneratorPreferences( ) KConfigDialog * Part::slotGeneratorPreferences( )
{ {
// Create dialog // Create dialog
KConfigDialog * dialog = new KConfigDialog( m_pageView, "generator_prefs", Okular::Settings::self() ); KConfigDialog * dialog = new KConfigDialog( m_pageView, "generator_prefs", Okular::Settings::self() );
@ -1053,6 +1053,8 @@ void Part::slotGeneratorPreferences( )
// Show it // Show it
dialog->setWindowModality( Qt::ApplicationModal ); dialog->setWindowModality( Qt::ApplicationModal );
dialog->show(); dialog->show();
return dialog;
} }

@ -37,6 +37,7 @@ class QPrinter;
class QMenu; class QMenu;
class KUrl; class KUrl;
class KConfigDialog;
class KConfigGroup; class KConfigGroup;
class KDirWatch; class KDirWatch;
class KToggleAction; class KToggleAction;
@ -221,6 +222,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void slotFileDirty( const QString& ); void slotFileDirty( const QString& );
void slotDoFileDirty(); void slotDoFileDirty();
void psTransformEnded(int, QProcess::ExitStatus); void psTransformEnded(int, QProcess::ExitStatus);
KConfigDialog * slotGeneratorPreferences();
private: private:
void setupViewerActions(); void setupViewerActions();
@ -332,7 +334,6 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
FileKeeper *m_keeper; FileKeeper *m_keeper;
private slots: private slots:
void slotGeneratorPreferences();
void slotAnnotationPreferences(); void slotAnnotationPreferences();
void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled); void slotHandleActivatedSourceReference(const QString& absFileName, int line, int col, bool *handled);
}; };

@ -12,6 +12,7 @@
#include "../part.h" #include "../part.h"
#include "../ui/toc.h" #include "../ui/toc.h"
#include <KConfigDialog>
#include <KStandardDirs> #include <KStandardDirs>
#include <KTempDir> #include <KTempDir>
@ -29,6 +30,7 @@ class PartTest
void testTOCReload(); void testTOCReload();
void testFowardPDF(); void testFowardPDF();
void testFowardPDF_data(); void testFowardPDF_data();
void testGeneratorPreferences();
}; };
void PartTest::testReload() void PartTest::testReload()
@ -93,6 +95,24 @@ void PartTest::testFowardPDF_data()
QTest::newRow("utf8") << QString(KGlobal::dirs()->resourceDirs("tmp")[0] + QString::fromUtf8("ßðđđŋßðđŋ")); 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[]) int main(int argc, char *argv[])

Loading…
Cancel
Save