Don't leak native dialog resources
Have QDialog::~QDialog() call deleteNativeDialog_sys() on the helpers, so that we don't risk leaking any resources allocated in the helper. QFileDialog does this now, but not QColorDialog or QFontDialog. The Cocoa plugin worked around this problem by calling deleteNativeDialog_sys() itself, but the Windows plugin does not do this, resulting in leaks. Change-Id: I380d87c95686c8f3cb260f9242299be27329280d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
parent
f280efc620
commit
cf48eded4d
@ -343,9 +343,7 @@ QCocoaColorDialogHelper::QCocoaColorDialogHelper() :
|
||||
}
|
||||
|
||||
QCocoaColorDialogHelper::~QCocoaColorDialogHelper()
|
||||
{
|
||||
deleteNativeDialog_sys();
|
||||
}
|
||||
{ }
|
||||
|
||||
void QCocoaColorDialogHelper::platformNativeDialogModalHelp()
|
||||
{
|
||||
|
@ -362,9 +362,7 @@ QCocoaFontDialogHelper::QCocoaFontDialogHelper() :
|
||||
}
|
||||
|
||||
QCocoaFontDialogHelper::~QCocoaFontDialogHelper()
|
||||
{
|
||||
deleteNativeDialog_sys();
|
||||
}
|
||||
{ }
|
||||
|
||||
void QCocoaFontDialogHelper::platformNativeDialogModalHelp()
|
||||
{
|
||||
|
@ -132,6 +132,14 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const
|
||||
return QPlatformDialogHelper::defaultStyleHint(hint);
|
||||
}
|
||||
|
||||
void QDialogPrivate::deleteNativeDialog()
|
||||
{
|
||||
if (QPlatformDialogHelper *helper = platformHelper()) {
|
||||
helper->deleteNativeDialog_sys();
|
||||
nativeDialogInUse = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QDialog
|
||||
\brief The QDialog class is the base class of dialog windows.
|
||||
@ -328,6 +336,7 @@ QDialog::QDialog(QDialogPrivate &dd, QWidget *parent, Qt::WindowFlags f)
|
||||
|
||||
QDialog::~QDialog()
|
||||
{
|
||||
Q_D(QDialog);
|
||||
QT_TRY {
|
||||
// Need to hide() here, as our (to-be) overridden hide()
|
||||
// will not be called in ~QWidget.
|
||||
@ -335,6 +344,7 @@ QDialog::~QDialog()
|
||||
} QT_CATCH(...) {
|
||||
// we're in the destructor - just swallow the exception
|
||||
}
|
||||
d->deleteNativeDialog();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
QWindow *parentWindow() const;
|
||||
bool setNativeDialogVisible(bool visible);
|
||||
QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
|
||||
void deleteNativeDialog();
|
||||
|
||||
QPointer<QPushButton> mainDef;
|
||||
Qt::Orientation orientation;
|
||||
|
@ -362,13 +362,11 @@ QFileDialog::QFileDialog(const QFileDialogArgs &args)
|
||||
*/
|
||||
QFileDialog::~QFileDialog()
|
||||
{
|
||||
Q_D(QFileDialog);
|
||||
#ifndef QT_NO_SETTINGS
|
||||
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
|
||||
settings.beginGroup(QLatin1String("Qt"));
|
||||
settings.setValue(QLatin1String("filedialog"), saveState());
|
||||
#endif
|
||||
d->deleteNativeDialog_sys();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1372,10 +1370,10 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode)
|
||||
d->qFileDialogUi->lookInCombo->setEditable(false);
|
||||
}
|
||||
d->retranslateWindowTitle();
|
||||
#if defined(Q_OS_MAC)
|
||||
d->deleteNativeDialog_sys();
|
||||
// we need to recreate the native dialog when changing the AcceptMode
|
||||
d->deleteNativeDialog();
|
||||
// clear WA_DontShowOnScreen so that d->canBeNativeDialog() doesn't return false incorrectly
|
||||
setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -244,7 +244,6 @@ public:
|
||||
// dialog. Returning false means that a non-native dialog must be
|
||||
// used instead.
|
||||
bool canBeNativeDialog();
|
||||
void deleteNativeDialog_sys();
|
||||
QDialog::DialogCode dialogResultCode_sys();
|
||||
|
||||
void setDirectory_sys(const QString &directory);
|
||||
@ -347,15 +346,6 @@ inline QString QFileDialogPrivate::rootPath() const {
|
||||
return model->rootPath();
|
||||
}
|
||||
|
||||
// Dummies for platforms that don't use native dialogs:
|
||||
inline void QFileDialogPrivate::deleteNativeDialog_sys()
|
||||
{
|
||||
if (QPlatformFileDialogHelper *helper = platformFileDialogHelper()) {
|
||||
helper->deleteNativeDialog_sys();
|
||||
nativeDialogInUse = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys()
|
||||
{
|
||||
QDialog::DialogCode result = QDialog::Rejected;
|
||||
|
Loading…
Reference in New Issue
Block a user