Commit 3dd3a000 authored by Fabio D'Urso's avatar Fabio D'Urso

Don't crash if Configure Backends is opened again after it's been closed

parent 8f1b2b72
...@@ -248,27 +248,12 @@ void TextDocumentGeneratorPrivate::initializeGenerator() ...@@ -248,27 +248,12 @@ void TextDocumentGeneratorPrivate::initializeGenerator()
q, SIGNAL(warning(QString,int)) ); q, SIGNAL(warning(QString,int)) );
QObject::connect( mConverter, SIGNAL(notice(QString,int)), QObject::connect( mConverter, SIGNAL(notice(QString,int)),
q, SIGNAL(notice(QString,int)) ); q, SIGNAL(notice(QString,int)) );
QObject::connect( mGeneralSettingsWidget, SIGNAL(destroyed()),
q, SLOT(generalSettingsWidgetDestroyed()) );
}
void TextDocumentGeneratorPrivate::generalSettingsWidgetDestroyed()
{
/**
* If addPage() is called from generator, it will install parent for this object,
* and parent will destroy this object before ~TextDocumentGeneratorPrivate()
*
* So just reset it.
*/
mGeneralSettingsWidget = 0;
} }
TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, const QString& configName, QObject *parent, const QVariantList &args ) TextDocumentGenerator::TextDocumentGenerator( TextDocumentConverter *converter, const QString& configName, QObject *parent, const QVariantList &args )
: Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args ) : Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
{ {
Q_D( TextDocumentGenerator ); Q_D( TextDocumentGenerator );
d->mGeneralSettingsWidget = new TextDocumentSettingsWidget();
d->mGeneralSettings = new TextDocumentSettings( configName, this ); d->mGeneralSettings = new TextDocumentSettings( configName, this );
d->initializeGenerator(); d->initializeGenerator();
...@@ -525,13 +510,7 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp ...@@ -525,13 +510,7 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp
bool TextDocumentGenerator::reparseConfig() bool TextDocumentGenerator::reparseConfig()
{ {
Q_D( TextDocumentGenerator ); Q_D( TextDocumentGenerator );
const QFont newFont = d->mGeneralSettings->font();
// don't have settings, just return "no changes".
if ( !d->mGeneralSettingsWidget ) {
return false;
}
const QFont newFont = d->mGeneralSettingsWidget->font();
if ( newFont != d->mFont ) { if ( newFont != d->mFont ) {
d->mFont = newFont; d->mFont = newFont;
...@@ -549,9 +528,7 @@ void TextDocumentGenerator::addPages( KConfigDialog* /*dlg*/ ) ...@@ -549,9 +528,7 @@ void TextDocumentGenerator::addPages( KConfigDialog* /*dlg*/ )
TextDocumentSettingsWidget* TextDocumentGenerator::generalSettingsWidget() TextDocumentSettingsWidget* TextDocumentGenerator::generalSettingsWidget()
{ {
Q_D( TextDocumentGenerator ); return new TextDocumentSettingsWidget();
return d->mGeneralSettingsWidget;
} }
TextDocumentSettings* TextDocumentGenerator::generalSettings() TextDocumentSettings* TextDocumentGenerator::generalSettings()
......
...@@ -224,7 +224,6 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator, public Okular::Con ...@@ -224,7 +224,6 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator, public Okular::Con
Q_PRIVATE_SLOT( d_func(), void addTitle( int, const QString&, const QTextBlock& ) ) Q_PRIVATE_SLOT( d_func(), void addTitle( int, const QString&, const QTextBlock& ) )
Q_PRIVATE_SLOT( d_func(), void addMetaData( const QString&, const QString&, const QString& ) ) Q_PRIVATE_SLOT( d_func(), void addMetaData( const QString&, const QString&, const QString& ) )
Q_PRIVATE_SLOT( d_func(), void addMetaData( DocumentInfo::Key, const QString& ) ) Q_PRIVATE_SLOT( d_func(), void addMetaData( DocumentInfo::Key, const QString& ) )
Q_PRIVATE_SLOT( d_func(), void generalSettingsWidgetDestroyed() )
}; };
} }
......
...@@ -114,7 +114,7 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate ...@@ -114,7 +114,7 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
public: public:
TextDocumentGeneratorPrivate( TextDocumentConverter *converter ) TextDocumentGeneratorPrivate( TextDocumentConverter *converter )
: mConverter( converter ), mDocument( 0 ), mGeneralSettingsWidget( 0 ), mGeneralSettings( 0 ) : mConverter( converter ), mDocument( 0 ), mGeneralSettings( 0 )
{ {
} }
...@@ -122,7 +122,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate ...@@ -122,7 +122,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
{ {
delete mConverter; delete mConverter;
delete mDocument; delete mDocument;
delete mGeneralSettingsWidget;
} }
void initializeGenerator(); void initializeGenerator();
...@@ -142,8 +141,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate ...@@ -142,8 +141,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
void addMetaData( const QString &key, const QString &value, const QString &title ); void addMetaData( const QString &key, const QString &value, const QString &title );
void addMetaData( DocumentInfo::Key, const QString &value ); void addMetaData( DocumentInfo::Key, const QString &value );
void generalSettingsWidgetDestroyed();
void generateLinkInfos(); void generateLinkInfos();
void generateAnnotationInfos(); void generateAnnotationInfos();
void generateTitleInfos(); void generateTitleInfos();
...@@ -194,7 +191,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate ...@@ -194,7 +191,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
}; };
QList<AnnotationInfo> mAnnotationInfos; QList<AnnotationInfo> mAnnotationInfos;
TextDocumentSettingsWidget *mGeneralSettingsWidget;
TextDocumentSettings *mGeneralSettings; TextDocumentSettings *mGeneralSettings;
QFont mFont; QFont mFont;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment