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()
|
QCocoaColorDialogHelper::~QCocoaColorDialogHelper()
|
||||||
{
|
{ }
|
||||||
deleteNativeDialog_sys();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QCocoaColorDialogHelper::platformNativeDialogModalHelp()
|
void QCocoaColorDialogHelper::platformNativeDialogModalHelp()
|
||||||
{
|
{
|
||||||
|
@ -362,9 +362,7 @@ QCocoaFontDialogHelper::QCocoaFontDialogHelper() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
QCocoaFontDialogHelper::~QCocoaFontDialogHelper()
|
QCocoaFontDialogHelper::~QCocoaFontDialogHelper()
|
||||||
{
|
{ }
|
||||||
deleteNativeDialog_sys();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QCocoaFontDialogHelper::platformNativeDialogModalHelp()
|
void QCocoaFontDialogHelper::platformNativeDialogModalHelp()
|
||||||
{
|
{
|
||||||
|
@ -132,6 +132,14 @@ QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const
|
|||||||
return QPlatformDialogHelper::defaultStyleHint(hint);
|
return QPlatformDialogHelper::defaultStyleHint(hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QDialogPrivate::deleteNativeDialog()
|
||||||
|
{
|
||||||
|
if (QPlatformDialogHelper *helper = platformHelper()) {
|
||||||
|
helper->deleteNativeDialog_sys();
|
||||||
|
nativeDialogInUse = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QDialog
|
\class QDialog
|
||||||
\brief The QDialog class is the base class of dialog windows.
|
\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()
|
QDialog::~QDialog()
|
||||||
{
|
{
|
||||||
|
Q_D(QDialog);
|
||||||
QT_TRY {
|
QT_TRY {
|
||||||
// Need to hide() here, as our (to-be) overridden hide()
|
// Need to hide() here, as our (to-be) overridden hide()
|
||||||
// will not be called in ~QWidget.
|
// will not be called in ~QWidget.
|
||||||
@ -335,6 +344,7 @@ QDialog::~QDialog()
|
|||||||
} QT_CATCH(...) {
|
} QT_CATCH(...) {
|
||||||
// we're in the destructor - just swallow the exception
|
// we're in the destructor - just swallow the exception
|
||||||
}
|
}
|
||||||
|
d->deleteNativeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
QWindow *parentWindow() const;
|
QWindow *parentWindow() const;
|
||||||
bool setNativeDialogVisible(bool visible);
|
bool setNativeDialogVisible(bool visible);
|
||||||
QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
|
QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const;
|
||||||
|
void deleteNativeDialog();
|
||||||
|
|
||||||
QPointer<QPushButton> mainDef;
|
QPointer<QPushButton> mainDef;
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
|
@ -362,13 +362,11 @@ QFileDialog::QFileDialog(const QFileDialogArgs &args)
|
|||||||
*/
|
*/
|
||||||
QFileDialog::~QFileDialog()
|
QFileDialog::~QFileDialog()
|
||||||
{
|
{
|
||||||
Q_D(QFileDialog);
|
|
||||||
#ifndef QT_NO_SETTINGS
|
#ifndef QT_NO_SETTINGS
|
||||||
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
|
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
|
||||||
settings.beginGroup(QLatin1String("Qt"));
|
settings.beginGroup(QLatin1String("Qt"));
|
||||||
settings.setValue(QLatin1String("filedialog"), saveState());
|
settings.setValue(QLatin1String("filedialog"), saveState());
|
||||||
#endif
|
#endif
|
||||||
d->deleteNativeDialog_sys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1372,10 +1370,10 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode)
|
|||||||
d->qFileDialogUi->lookInCombo->setEditable(false);
|
d->qFileDialogUi->lookInCombo->setEditable(false);
|
||||||
}
|
}
|
||||||
d->retranslateWindowTitle();
|
d->retranslateWindowTitle();
|
||||||
#if defined(Q_OS_MAC)
|
// we need to recreate the native dialog when changing the AcceptMode
|
||||||
d->deleteNativeDialog_sys();
|
d->deleteNativeDialog();
|
||||||
|
// clear WA_DontShowOnScreen so that d->canBeNativeDialog() doesn't return false incorrectly
|
||||||
setAttribute(Qt::WA_DontShowOnScreen, false);
|
setAttribute(Qt::WA_DontShowOnScreen, false);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -244,7 +244,6 @@ public:
|
|||||||
// dialog. Returning false means that a non-native dialog must be
|
// dialog. Returning false means that a non-native dialog must be
|
||||||
// used instead.
|
// used instead.
|
||||||
bool canBeNativeDialog();
|
bool canBeNativeDialog();
|
||||||
void deleteNativeDialog_sys();
|
|
||||||
QDialog::DialogCode dialogResultCode_sys();
|
QDialog::DialogCode dialogResultCode_sys();
|
||||||
|
|
||||||
void setDirectory_sys(const QString &directory);
|
void setDirectory_sys(const QString &directory);
|
||||||
@ -347,15 +346,6 @@ inline QString QFileDialogPrivate::rootPath() const {
|
|||||||
return model->rootPath();
|
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()
|
inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys()
|
||||||
{
|
{
|
||||||
QDialog::DialogCode result = QDialog::Rejected;
|
QDialog::DialogCode result = QDialog::Rejected;
|
||||||
|
Loading…
Reference in New Issue
Block a user