Commit 7cda7c95 authored by Christoph Roick's avatar Christoph Roick
Browse files

Fix crashy dialogs (found by krazy and by hand)

Summary:
- use a wrapper class which simplifies the use of QPointer
  for the creation of local QDialogs
- some false positives are marked
- some dialogs not identified by krazy have the main window
  as parent, they may still cause a crash, when the program is killed

Test Plan:
Before:
- open "About KDevelop Platform" dialog
- "killall kdevelop" -> kdevelop closes (as intended), but with crash
After:
- open same dialog
- "killall kdevelop" -> kdevelop silently quits

Reviewers: #kdevelop, apol

Reviewed By: #kdevelop, apol

Subscribers: apol, anthonyfieroni, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D6308
parent c6dd6e64
......@@ -309,8 +309,7 @@ BasicRefactoring::NameAndCollector BasicRefactoring::newNameForDeclaration(const
const auto text = renameDialog.edit->text().trimmed();
RefactoringProgressDialog refactoringProgress(i18n("Renaming \"%1\" to \"%2\"", declarationName, text), collector.data());
if (!collector->isReady()) {
refactoringProgress.exec();
if (refactoringProgress.result() != QDialog::Accepted) {
if (refactoringProgress.exec() != QDialog::Accepted) { // krazy:exclude=crashy
return {};
}
}
......
......@@ -46,6 +46,7 @@
#include <interfaces/idocumentcontroller.h>
#include <interfaces/context.h>
#include <interfaces/contextmenuextension.h>
#include <util/scopeddialog.h>
#include <vcs/vcsjob.h>
#include <vcs/interfaces/icentralizedversioncontrol.h>
#include <vcs/interfaces/idistributedversioncontrol.h>
......@@ -84,16 +85,16 @@ void AppWizardPlugin::slotNewProject()
{
model()->refresh();
AppWizardDialog dlg(core()->pluginController(), m_templatesModel);
ScopedDialog<AppWizardDialog> dlg(core()->pluginController(), m_templatesModel);
if (dlg.exec() == QDialog::Accepted)
if (dlg->exec() == QDialog::Accepted)
{
QString project = createProject( dlg.appInfo() );
QString project = createProject( dlg->appInfo() );
if (!project.isEmpty())
{
core()->projectController()->openProject(QUrl::fromLocalFile(project));
KConfig templateConfig(dlg.appInfo().appTemplate);
KConfig templateConfig(dlg->appInfo().appTemplate);
KConfigGroup general(&templateConfig, "General");
const QStringList fileArgs = general.readEntry("ShowFilesAfterGeneration").split(QLatin1Char(','), QString::SkipEmptyParts);
for (const auto& fileArg : fileArgs) {
......
......@@ -26,6 +26,7 @@
#include <language/codegen/templatepreviewicon.h>
#include <util/multilevellistview.h>
#include <util/scopeddialog.h>
#include "ui_projectselectionpage.h"
#include "projecttemplatesmodel.h"
......@@ -305,15 +306,15 @@ void ProjectSelectionPage::loadFileClicked()
QStringLiteral("application/x-bzip-compressed-tar"),
QStringLiteral("application/zip")
};
QFileDialog fileDialog(this, i18n("Load Template From File"));
fileDialog.setMimeTypeFilters(supportedMimeTypes);
fileDialog.setFileMode(QFileDialog::ExistingFiles);
ScopedDialog<QFileDialog> fileDialog(this, i18n("Load Template From File"));
fileDialog->setMimeTypeFilters(supportedMimeTypes);
fileDialog->setFileMode(QFileDialog::ExistingFiles);
if (!fileDialog.exec()) {
if (!fileDialog->exec()) {
return;
}
for (const auto& fileName : fileDialog.selectedFiles()) {
for (const auto& fileName : fileDialog->selectedFiles()) {
QString destination = m_templatesModel->loadTemplateFile(fileName);
QModelIndexList indexes = m_templatesModel->templateIndexes(destination);
if (indexes.size() > 2)
......@@ -326,10 +327,12 @@ void ProjectSelectionPage::loadFileClicked()
void ProjectSelectionPage::moreTemplatesClicked()
{
KNS3::DownloadDialog dialog(QStringLiteral("kdevappwizard.knsrc"), this);
dialog.exec();
ScopedDialog<KNS3::DownloadDialog> dialog(QStringLiteral("kdevappwizard.knsrc"), this);
auto entries = dialog.changedEntries();
if (!dialog->exec())
return;
auto entries = dialog->changedEntries();
if (entries.isEmpty()) {
return;
}
......
......@@ -32,6 +32,8 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <util/scopeddialog.h>
ExternalScriptView::ExternalScriptView( ExternalScriptPlugin* plugin, QWidget* parent )
: QWidget( parent ), m_plugin( plugin )
......@@ -135,9 +137,8 @@ bool ExternalScriptView::eventFilter( QObject* obj, QEvent* e )
void ExternalScriptView::addScript()
{
ExternalScriptItem* item = new ExternalScriptItem;
EditExternalScript dlg( item, this );
int ret = dlg.exec();
if ( ret == QDialog::Accepted) {
KDevelop::ScopedDialog<EditExternalScript> dlg( item, this );
if ( dlg->exec() == QDialog::Accepted) {
m_plugin->model()->appendRow( item );
} else {
delete item;
......@@ -170,9 +171,8 @@ void ExternalScriptView::editScript()
return;
}
EditExternalScript dlg( item, this );
int ret = dlg.exec();
if (ret == QDialog::Accepted) {
KDevelop::ScopedDialog<EditExternalScript> dlg( item, this );
if (dlg->exec() == QDialog::Accepted) {
item->save();
}
}
......
......@@ -45,12 +45,12 @@
#include <project/projectmodel.h>
#include <project/interfaces/iprojectfilemanager.h>
#include <project/interfaces/ibuildsystemmanager.h>
#include <util/scopeddialog.h>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QPointer>
#include <QPushButton>
#include <QVBoxLayout>
......@@ -198,7 +198,7 @@ void TemplateClassAssistantPrivate::addFilesToTarget (const QHash< QString, QUrl
else if (targets.size() > 1)
{
// More than one candidate target, show the chooser dialog
QPointer<QDialog> d = new QDialog;
ScopedDialog<QDialog> d;
auto mainLayout = new QVBoxLayout(d);
mainLayout->addWidget(new QLabel(i18n("Choose one target to add the file or cancel if you do not want to do so.")));
......@@ -215,8 +215,8 @@ void TemplateClassAssistantPrivate::addFilesToTarget (const QHash< QString, QUrl
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
d->connect(buttonBox, &QDialogButtonBox::accepted, d.data(), &QDialog::accept);
d->connect(buttonBox, &QDialogButtonBox::rejected, d.data(), &QDialog::reject);
d->connect(buttonBox, &QDialogButtonBox::accepted, d, &QDialog::accept);
d->connect(buttonBox, &QDialogButtonBox::rejected, d, &QDialog::reject);
mainLayout->addWidget(buttonBox);
if(d->exec() == QDialog::Accepted)
......
......@@ -32,6 +32,7 @@
#include <interfaces/iproject.h>
#include <interfaces/iprojectcontroller.h>
#include <interfaces/isession.h>
#include <util/scopeddialog.h>
#include "ui_templateselection.h"
......@@ -159,16 +160,16 @@ void TemplateSelectionPagePrivate::loadFileClicked()
QStringLiteral("application/x-bzip-compressed-tar"),
QStringLiteral("application/zip")
};
QFileDialog dlg(page);
dlg.setMimeTypeFilters(filters);
dlg.setFileMode(QFileDialog::ExistingFiles);
ScopedDialog<QFileDialog> dlg(page);
dlg->setMimeTypeFilters(filters);
dlg->setFileMode(QFileDialog::ExistingFiles);
if (!dlg.exec())
if (!dlg->exec())
{
return;
}
foreach(const QString& fileName, dlg.selectedFiles())
foreach(const QString& fileName, dlg->selectedFiles())
{
QString destination = model->loadTemplateFile(fileName);
QModelIndexList indexes = model->templateIndexes(destination);
......
......@@ -516,7 +516,7 @@ void GitPlugin::addNotVersionedFiles(const QDir& dir, const QList<QUrl>& files)
if(!toadd.isEmpty()) {
VcsJob* job = add(toadd);
job->exec();
job->exec(); // krazy:exclude=crashy
}
}
......
......@@ -404,7 +404,7 @@ void KDevSvnPlugin::ctxCopy()
dlg.urlRequester()->setMode(KFile::Directory | KFile::LocalOnly);
}
if (dlg.exec() == QDialog::Accepted) {
if (dlg.exec() == QDialog::Accepted) { // krazy:exclude=crashy
KDevelop::ICore::self()->runController()->registerJob(copy(source, dlg.selectedUrl()));
}
} else {
......@@ -440,7 +440,7 @@ void KDevSvnPlugin::ctxMove()
dlg.urlRequester()->setMode(KFile::Directory | KFile::LocalOnly);
}
if (dlg.exec() == QDialog::Accepted) {
if (dlg.exec() == QDialog::Accepted) { // krazy:exclude=crashy
KDevelop::ICore::self()->runController()->registerJob(move(source, dlg.selectedUrl()));
}
} else {
......
......@@ -68,11 +68,12 @@ void SvnJobBase::askForLogin( const QString& realm )
qCDebug(PLUGIN_SVN) << "login";
KPasswordDialog dlg( nullptr, KPasswordDialog::ShowUsernameLine | KPasswordDialog::ShowKeepPassword );
dlg.setPrompt( i18n("Enter Login for: %1", realm ) );
dlg.exec();
internalJob()->m_login_username = dlg.username();
internalJob()->m_login_password = dlg.password();
internalJob()->m_maySave = dlg.keepPassword();
internalJob()->m_guiSemaphore.release( 1 );
if (dlg.exec()) { // krazy:exclude=crashy
internalJob()->m_login_username = dlg.username();
internalJob()->m_login_password = dlg.password();
internalJob()->m_maySave = dlg.keepPassword();
internalJob()->m_guiSemaphore.release( 1 );
}
}
void SvnJobBase::showNotification( const QString& path, const QString& msg )
......
......@@ -54,6 +54,7 @@ Boston, MA 02110-1301, USA.
#include <interfaces/iselectioncontroller.h>
#include <interfaces/context.h>
#include <project/projectmodel.h>
#include <util/scopeddialog.h>
#include <util/path.h>
#include "core.h"
......@@ -813,9 +814,8 @@ bool KDevelop::DocumentController::saveSomeDocuments(const QList< IDocument * >
QList<IDocument*> checkSave = modifiedDocuments(list);
if (!checkSave.isEmpty()) {
KSaveSelectDialog dialog(checkSave, qApp->activeWindow());
if (dialog.exec() == QDialog::Rejected)
return false;
ScopedDialog<KSaveSelectDialog> dialog(checkSave, qApp->activeWindow());
return dialog->exec();
}
}
......
......@@ -29,6 +29,8 @@
#include <QIcon>
#include <QVBoxLayout>
#include <util/scopeddialog.h>
#include <KLocalizedString>
namespace KDevelop {
......@@ -43,31 +45,31 @@ public:
void showDialog()
{
QDialog dlg(qApp->activeWindow());
ScopedDialog<QDialog> dlg(qApp->activeWindow());
QString selected;
if (selectionWidget) {
selected = selectionWidget->effectiveProfileName();
}
EnvironmentPreferences prefs(selected, q);
auto prefs = new EnvironmentPreferences(selected, q);
// TODO: This should be implicit when constructing EnvironmentPreferences
prefs.initConfigManager();
prefs.reset();
prefs->initConfigManager();
prefs->reset();
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject);
auto layout = new QVBoxLayout;
layout->addWidget(&prefs);
layout->addWidget(prefs);
layout->addWidget(buttonBox);
dlg.setLayout(layout);
dlg.setWindowTitle(prefs.fullName());
dlg.setWindowIcon(prefs.icon());
dlg.resize(800, 600);
if (dlg.exec() == QDialog::Accepted) {
prefs.apply();
dlg->setLayout(layout);
dlg->setWindowTitle(prefs->fullName());
dlg->setWindowIcon(prefs->icon());
dlg->resize(800, 600);
if (dlg->exec() == QDialog::Accepted) {
prefs->apply();
emit q->environmentConfigured();
}
}
......
......@@ -34,6 +34,8 @@
#include <KTitleWidget>
#include <KWidgetItemDelegate>
#include <util/scopeddialog.h>
#include "core.h"
#include "plugincontroller.h"
......@@ -240,8 +242,8 @@ private Q_SLOTS:
if (p) {
KAboutData aboutData = KAboutData::fromPluginMetaData(pluginInfo(p));
if (!aboutData.componentName().isEmpty()) { // Be sure the about data is not completely empty
KAboutApplicationDialog aboutPlugin(aboutData, itemView());
aboutPlugin.exec();
KDevelop::ScopedDialog<KAboutApplicationDialog> aboutPlugin(aboutData, itemView());
aboutPlugin->exec();
return;
}
}
......
......@@ -40,6 +40,7 @@ Boston, MA 02110-1301, USA.
#include "loadedpluginsdialog.h"
#include <interfaces/itoolviewactionlistener.h>
#include <util/scopeddialog.h>
namespace KDevelop {
......@@ -206,14 +207,14 @@ void MainWindowPrivate::configureNotifications()
void MainWindowPrivate::showAboutPlatform()
{
KAboutApplicationDialog dlg(Core::self()->aboutData(), m_mainWindow );
dlg.exec();
ScopedDialog<KAboutApplicationDialog> dlg(Core::self()->aboutData(), m_mainWindow );
dlg->exec();
}
void MainWindowPrivate::showLoadedPlugins()
{
LoadedPluginsDialog dlg(m_mainWindow);
dlg.exec();
ScopedDialog<LoadedPluginsDialog> dlg(m_mainWindow);
dlg->exec();
}
void MainWindowPrivate::contextMenuFileNew()
......
......@@ -29,6 +29,7 @@ Boston, MA 02110-1301, USA.
#include <QLabel>
#include <QList>
#include <QMap>
#include <QPointer>
#include <QPushButton>
#include <QRadioButton>
#include <QSet>
......@@ -63,6 +64,7 @@ Boston, MA 02110-1301, USA.
#include <projectconfigpage.h>
#include <language/backgroundparser/parseprojectjob.h>
#include <interfaces/iruncontroller.h>
#include <util/scopeddialog.h>
#include <vcs/widgets/vcsdiffpatchsources.h>
#include <vcs/widgets/vcscommitdialog.h>
......@@ -419,13 +421,15 @@ QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& sta
const QUrl& repoUrl, IPlugin* vcsOrProviderPlugin)
{
Q_ASSERT(d);
OpenProjectDialog dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin, Core::self()->uiController()->activeMainWindow());
if(dlg.exec() == QDialog::Rejected)
ScopedDialog<OpenProjectDialog> dlg(fetch, startUrl, repoUrl, vcsOrProviderPlugin,
Core::self()->uiController()->activeMainWindow());
if(dlg->exec() == QDialog::Rejected) {
return QUrl();
}
QUrl projectFileUrl = dlg.projectFileUrl();
qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg.projectName() << dlg.projectManager();
if ( dlg.projectManager() == QLatin1String("<built-in>") ) {
QUrl projectFileUrl = dlg->projectFileUrl();
qCDebug(SHELL) << "selected project:" << projectFileUrl << dlg->projectName() << dlg->projectManager();
if ( dlg->projectManager() == QLatin1String("<built-in>") ) {
return projectFileUrl;
}
......@@ -435,11 +439,11 @@ QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& sta
{
// check whether config is equal
bool shouldAsk = true;
if( projectFileUrl == dlg.selectedUrl() )
if( projectFileUrl == dlg->selectedUrl() )
{
if( projectFileUrl.isLocalFile() )
{
shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), &dlg );
shouldAsk = !equalProjectFile( projectFileUrl.toLocalFile(), dlg );
} else {
shouldAsk = false;
......@@ -448,7 +452,7 @@ QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& sta
auto downloadJob = KIO::file_copy(projectFileUrl, QUrl::fromLocalFile(tmpFile.fileName()));
KJobWidgets::setWindow(downloadJob, qApp->activeWindow());
if (downloadJob->exec()) {
shouldAsk = !equalProjectFile(tmpFile.fileName(), &dlg);
shouldAsk = !equalProjectFile(tmpFile.fileName(), dlg);
}
}
}
......@@ -483,12 +487,13 @@ QUrl ProjectDialogProvider::askProjectConfigLocation(bool fetch, const QUrl& sta
}
if (writeProjectConfigToFile) {
if (!writeProjectSettingsToConfigFile(projectFileUrl, &dlg)) {
if (!writeProjectSettingsToConfigFile(projectFileUrl, dlg)) {
KMessageBox::error(d->m_core->uiControllerInternal()->defaultMainWindow(),
i18n("Unable to create configuration file %1", projectFileUrl.url()));
return QUrl();
}
}
return projectFileUrl;
}
......@@ -785,10 +790,10 @@ void ProjectController::openProject( const QUrl &projectFile )
}
if ( ! existingSessions.isEmpty() ) {
QDialog dialog(Core::self()->uiControllerInternal()->activeMainWindow());
dialog.setWindowTitle(i18n("Project Already Open"));
ScopedDialog<QDialog> dialog(Core::self()->uiControllerInternal()->activeMainWindow());
dialog->setWindowTitle(i18n("Project Already Open"));
auto mainLayout = new QVBoxLayout(&dialog);
auto mainLayout = new QVBoxLayout(dialog);
mainLayout->addWidget(new QLabel(i18n("The project you're trying to open is already open in at least one "
"other session.<br>What do you want to do?")));
QGroupBox sessions;
......@@ -808,12 +813,11 @@ void ProjectController::openProject( const QUrl &projectFile )
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
mainLayout->addWidget(buttonBox);
bool success = dialog.exec();
if (!success)
if (!dialog->exec())
return;
foreach ( const QObject* obj, sessions.children() ) {
......@@ -1158,7 +1162,7 @@ void ProjectController::commitCurrentProject()
bool ret = showVcsDiff(patchSource);
if(!ret) {
VcsCommitDialog *commitDialog = new VcsCommitDialog(patchSource);
ScopedDialog<VcsCommitDialog> commitDialog(patchSource);
commitDialog->setCommitCandidates(patchSource->infos());
commitDialog->exec();
}
......
......@@ -614,7 +614,7 @@ QString SessionController::showSessionChooserDialog(QString headerText, bool onl
///@todo We need a way to get a proper size-hint from the view, but unfortunately, that only seems possible after the view was shown.
dialog.resize(QSize(900, 600));
if(dialog.exec() != QDialog::Accepted)
if(dialog.exec() != QDialog::Accepted) // krazy:exclude=crashy
{
return QString();
}
......
......@@ -33,6 +33,8 @@ Boston, MA 02110-1301, USA.
#include <QHBoxLayout>
#include <QValidator>
#include <util/scopeddialog.h>
#include <KLocalizedString>
#include "environmentprofilelistmodel.h"
......@@ -176,10 +178,10 @@ void EnvironmentWidget::defaults( KConfig* config )
QString EnvironmentWidget::askNewProfileName(const QString& defaultName)
{
QDialog dialog(this);
dialog.setWindowTitle(i18n("Enter Name of New Environment Profile"));
ScopedDialog<QDialog> dialog(this);
dialog->setWindowTitle(i18n("Enter Name of New Environment Profile"));
QVBoxLayout *layout = new QVBoxLayout(&dialog);
QVBoxLayout *layout = new QVBoxLayout(dialog);
auto editLayout = new QHBoxLayout;
......@@ -193,11 +195,11 @@ QString EnvironmentWidget::askNewProfileName(const QString& defaultName)
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setEnabled(false);
okButton->setDefault(true);
dialog.connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
dialog.connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
dialog->connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
dialog->connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
layout->addWidget(buttonBox);
auto validator = new ProfileNameValidator(m_environmentProfileListModel, &dialog);
auto validator = new ProfileNameValidator(m_environmentProfileListModel, dialog);
connect(edit, &QLineEdit::textChanged, validator, [validator, okButton](const QString& text) {
int pos;
QString t(text);
......@@ -208,7 +210,7 @@ QString EnvironmentWidget::askNewProfileName(const QString& defaultName)
edit->setText(defaultName);
edit->selectAll();
if (dialog.exec() != QDialog::Accepted) {
if (dialog->exec() != QDialog::Accepted) {
return {};
}
......@@ -239,10 +241,10 @@ void EnvironmentWidget::onVariableInserted(int column, const QVariant& value)
void EnvironmentWidget::batchModeEditButtonClicked()
{
QDialog dialog(this);
dialog.setWindowTitle( i18n( "Batch Edit Mode" ) );
ScopedDialog<QDialog> dialog(this);
dialog->setWindowTitle( i18n( "Batch Edit Mode" ) );
QVBoxLayout *layout = new QVBoxLayout(&dialog);
QVBoxLayout *layout = new QVBoxLayout(dialog);
auto edit = new QPlainTextEdit;
edit->setPlaceholderText(QStringLiteral("VARIABLE1=VALUE1\nVARIABLE2=VALUE2"));
......@@ -259,13 +261,13 @@ void EnvironmentWidget::batchModeEditButtonClicked()
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
dialog.connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
dialog.connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
dialog->connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
dialog->connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
layout->addWidget(buttonBox);
dialog.resize(600, 400);
dialog->resize(600, 400);
if ( dialog.exec() != QDialog::Accepted ) {
if ( dialog->exec() != QDialog::Accepted ) {
return;
}
......
......@@ -38,6 +38,7 @@ Boston, MA 02110-1301, USA.
#include <shell/core.h>
#include <shell/plugincontroller.h>
#include <shell/languagecontroller.h>
#include <util/scopeddialog.h>
#include "editstyledialog.h"
#include "debug.h"
......@@ -401,10 +402,10 @@ void SourceFormatterSettings::editStyle()
QMimeType mimetype = l.mimetypes.first();
if( QScopedPointer<QObject>(fmt->formatter->editStyleWidget( mimetype )) ) {
EditStyleDialog dlg( fmt->formatter, mimetype, *l.selectedStyle, this );
if( dlg.exec() == QDialog::Accepted )
KDevelop::ScopedDialog<EditStyleDialog> dlg(fmt->formatter, mimetype, *l.selectedStyle, this);
if( dlg->exec() == QDialog::Accepted )
{
l.selectedStyle->setContent(dlg.content());
l.selectedStyle->setContent(dlg->content());
}
updatePreview();
emit changed();
......
......@@ -22,6 +22,7 @@
#include "ui_templatepage.h"
#include "qtcompat_p.h"
#include <QFileDialog>
#include <interfaces/itemplateprovider.h>
#include <language/codegen/templatesmodel.h>
......@@ -32,7 +33,7 @@
#include <KZip>
#include <KTar>
#include <QFileDialog>
#include <util/scopeddialog.h>
TemplatePage::TemplatePage (KDevelop::ITemplateProvider* provider, QWidget* parent) : QWidget (parent),
m_provider(provider)
......@@ -70,14 +71,14 @@ TemplatePage::~TemplatePage()
void TemplatePage::loadFromFile()
{
QFileDialog fileDialog(this);
fileDialog.setMimeTypeFilters(m_provider->supportedMimeTypes());
fileDialog.setFileMode(QFileDialog::ExistingFiles);
if (!fileDialog.exec()) {