Prevent memory leaks found via valgrind
This commit is contained in:
parent
abb9f5790a
commit
55341a7305
|
@ -116,7 +116,7 @@ void loadQtTranslationFile(initializer_list<QString> repositoryNames, const QStr
|
|||
{
|
||||
const auto debugTranslations = qEnvironmentVariableIsSet("QT_DEBUG_TRANSLATIONS");
|
||||
for (const auto &repoName : repositoryNames) {
|
||||
auto *const qtTranslator = new QTranslator;
|
||||
auto *const qtTranslator = new QTranslator(QCoreApplication::instance());
|
||||
const auto fileName = QString(repoName % QChar('_') % localeName);
|
||||
|
||||
QString path;
|
||||
|
@ -216,7 +216,7 @@ void logTranslationEvent(
|
|||
*/
|
||||
void loadApplicationTranslationFile(const QString &configName, const QString &applicationName, const QString &localeName)
|
||||
{
|
||||
auto *const appTranslator = new QTranslator;
|
||||
auto *const appTranslator = new QTranslator(QCoreApplication::instance());
|
||||
const auto fileName = QString(applicationName % QChar('_') % localeName);
|
||||
const auto directoryName = configName.isEmpty() ? applicationName : QString(applicationName % QChar('-') % configName);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace QtUtilities {
|
|||
* file/directory via QFileDialog.
|
||||
*/
|
||||
|
||||
QCompleter *PathSelection::m_completer = nullptr;
|
||||
QCompleter *PathSelection::s_completer = nullptr;
|
||||
|
||||
/*!
|
||||
* \brief Constructs a path selection widget.
|
||||
|
@ -41,21 +41,21 @@ PathSelection::PathSelection(QWidget *parent)
|
|||
, m_customDialog(nullptr)
|
||||
, m_customMode(QFileDialog::Directory)
|
||||
{
|
||||
if (!m_completer) {
|
||||
auto *fileSystemModel = new QFileSystemModel(m_completer);
|
||||
if (!s_completer) {
|
||||
s_completer = new QCompleter;
|
||||
s_completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
|
||||
auto *const fileSystemModel = new QFileSystemModel(s_completer);
|
||||
fileSystemModel->setRootPath(QString());
|
||||
m_completer = new QCompleter;
|
||||
m_completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
|
||||
m_completer->setModel(fileSystemModel);
|
||||
s_completer->setModel(fileSystemModel);
|
||||
}
|
||||
|
||||
m_lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
m_lineEdit->installEventFilter(this);
|
||||
m_lineEdit->setCompleter(m_completer);
|
||||
m_lineEdit->setCompleter(s_completer);
|
||||
m_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
m_button->setText(tr("Select ..."));
|
||||
|
||||
auto *layout = new QHBoxLayout(this);
|
||||
auto *const layout = new QHBoxLayout(this);
|
||||
layout->setSpacing(3);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(m_lineEdit);
|
||||
|
|
|
@ -34,7 +34,7 @@ private:
|
|||
QPushButton *m_button;
|
||||
QFileDialog *m_customDialog;
|
||||
QFileDialog::FileMode m_customMode;
|
||||
static QCompleter *m_completer;
|
||||
static QCompleter *s_completer;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue