<commit_before>#include "preferencesDialog.h"
#include "ui_preferencesDialog.h"

#include "preferencesPages/behaviourPage.h"
#include "preferencesPages/compilerPage.h"
#include "preferencesPages/debuggerPage.h"
#include "preferencesPages/editorPage.h"
#include "preferencesPages/miscellaniousPage.h"
#include "preferencesPages/featuresPage.h"

PreferencesDialog::PreferencesDialog(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::PreferencesDialog)
	, mBehaviourPage(NULL)
	, mCompilerPage(NULL)
	, mDebuggerPage(NULL)
	, mEditorPage(NULL)
	, mMiscellaniousPage(NULL)
	, mFeaturesPage(NULL)
{
	ui->setupUi(this);
}

PreferencesDialog::~PreferencesDialog()
{
	SettingsManager::setValue("currentPreferencesTab", ui->listWidget->currentRow());

	delete ui;

	delete mBehaviourPage;
	delete mCompilerPage;
	delete mDebuggerPage;
	delete mEditorPage;
	delete mMiscellaniousPage;
	delete mFeaturesPage;

//	foreach (PreferencesPage *page, mCustomPages.values())
//		delete page;
}

void PreferencesDialog::init(QAction * const showGridAction, QAction * const showAlignmentAction
	,QAction * const activateGridAction, QAction * const activateAlignmentAction)
{
	mBehaviourPage = new PreferencesBehaviourPage(ui->pageContentWigdet);
	mCompilerPage = new PreferencesCompilerPage(ui->pageContentWigdet);
	mDebuggerPage = new PreferencesDebuggerPage(ui->pageContentWigdet);
	mMiscellaniousPage = new PreferencesMiscellaniousPage(ui->pageContentWigdet);
	mFeaturesPage = new PreferencesFeaturesPage(ui->pageContentWigdet);
	mEditorPage = new PreferencesEditorPage(showGridAction,
		showAlignmentAction, activateGridAction, activateAlignmentAction, ui->pageContentWigdet);

	connect(ui->listWidget, SIGNAL(clicked(const QModelIndex &)), this, SLOT(chooseTab(const QModelIndex &)));
	connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(applyChanges()));
	connect(ui->okButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
	connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));<commit_msg>fixed segfault on exit. closed #199<commit_after>#include "preferencesDialog.h"
#include "ui_preferencesDialog.h"

#include "preferencesPages/behaviourPage.h"
#include "preferencesPages/compilerPage.h"
#include "preferencesPages/debuggerPage.h"
#include "preferencesPages/editorPage.h"
#include "preferencesPages/miscellaniousPage.h"
#include "preferencesPages/featuresPage.h"

PreferencesDialog::PreferencesDialog(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::PreferencesDialog)
	, mBehaviourPage(NULL)
	, mCompilerPage(NULL)
	, mDebuggerPage(NULL)
	, mEditorPage(NULL)
	, mMiscellaniousPage(NULL)
	, mFeaturesPage(NULL)
{
	ui->setupUi(this);
}

PreferencesDialog::~PreferencesDialog()
{
	SettingsManager::setValue("currentPreferencesTab", ui->listWidget->currentRow());

	// UIs of custom pages should be deleted from plugins, so we nullify their parents here
	// to prevent double destruction
	foreach (PreferencesPage *page, mCustomPages.values())
		page->setParent(NULL);

	delete ui;

	delete mBehaviourPage;
	delete mCompilerPage;
	delete mDebuggerPage;
	delete mEditorPage;
	delete mMiscellaniousPage;
	delete mFeaturesPage;
}

void PreferencesDialog::init(QAction * const showGridAction, QAction * const showAlignmentAction
	,QAction * const activateGridAction, QAction * const activateAlignmentAction)
{
	mBehaviourPage = new PreferencesBehaviourPage(ui->pageContentWigdet);
	mCompilerPage = new PreferencesCompilerPage(ui->pageContentWigdet);
	mDebuggerPage = new PreferencesDebuggerPage(ui->pageContentWigdet);
	mMiscellaniousPage = new PreferencesMiscellaniousPage(ui->pageContentWigdet);
	mFeaturesPage = new PreferencesFeaturesPage(ui->pageContentWigdet);
	mEditorPage = new PreferencesEditorPage(showGridAction,
		showAlignmentAction, activateGridAction, activateAlignmentAction, ui->pageContentWigdet);

	connect(ui->listWidget, SIGNAL(clicked(const QModelIndex &)), this, SLOT(chooseTab(const QModelIndex &)));
	connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(applyChanges()));
	connect(ui->okButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
	connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
{'fraction_non_alphanumeric': 0.11615551799082348, 'fraction_numerical': 0.0007244626901714562, 'mean_word_length': 8.587962962962964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1348000', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1286, 'n_words': 230}