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()
q, SIGNAL(warning(QString,int)) );
QObject::connect( mConverter, 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 )
: Okular::Generator( *new TextDocumentGeneratorPrivate( converter ), parent, args )
{
Q_D( TextDocumentGenerator );
d->mGeneralSettingsWidget = new TextDocumentSettingsWidget();
d->mGeneralSettings = new TextDocumentSettings( configName, this );
d->initializeGenerator();
......@@ -525,13 +510,7 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp
bool TextDocumentGenerator::reparseConfig()
{
Q_D( TextDocumentGenerator );
// don't have settings, just return "no changes".
if ( !d->mGeneralSettingsWidget ) {
return false;
}
const QFont newFont = d->mGeneralSettingsWidget->font();
const QFont newFont = d->mGeneralSettings->font();
if ( newFont != d->mFont ) {
d->mFont = newFont;
......@@ -549,9 +528,7 @@ void TextDocumentGenerator::addPages( KConfigDialog* /*dlg*/ )
TextDocumentSettingsWidget* TextDocumentGenerator::generalSettingsWidget()
{
Q_D( TextDocumentGenerator );
return d->mGeneralSettingsWidget;
return new TextDocumentSettingsWidget();
}
TextDocumentSettings* TextDocumentGenerator::generalSettings()
......
......@@ -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 addMetaData( const QString&, const QString&, 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
public:
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
{
delete mConverter;
delete mDocument;
delete mGeneralSettingsWidget;
}
void initializeGenerator();
......@@ -142,8 +141,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
void addMetaData( const QString &key, const QString &value, const QString &title );
void addMetaData( DocumentInfo::Key, const QString &value );
void generalSettingsWidgetDestroyed();
void generateLinkInfos();
void generateAnnotationInfos();
void generateTitleInfos();
......@@ -194,7 +191,6 @@ class TextDocumentGeneratorPrivate : public GeneratorPrivate
};
QList<AnnotationInfo> mAnnotationInfos;
TextDocumentSettingsWidget *mGeneralSettingsWidget;
TextDocumentSettings *mGeneralSettings;
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