Skip to content

Commit a4e2271

Browse files
committed
Fix memleak for detached SmartDock
1 parent 8a01af3 commit a4e2271

File tree

22 files changed

+35
-40
lines changed

22 files changed

+35
-40
lines changed

plugins/robots/common/twoDModel/include/twoDModel/engine/twoDModelEngineFacade.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public slots:
7676
QScopedPointer<model::Model> mModel;
7777
QPointer<view::TwoDModelWidget> mView {};
7878
QScopedPointer<TwoDModelEngineInterface> mApi;
79-
utils::SmartDock *mDock; // Transfers ownership to main window indirectly
79+
utils::SmartDock *mDock {}; // Transfers ownership to main window indirectly
8080

8181
qReal::TabInfo::TabType mCurrentTabInfo { qReal::TabInfo::TabType::other }; // temp hack
8282
};

plugins/robots/common/twoDModel/src/engine/twoDModelEngineFacade.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ TwoDModelEngineFacade::TwoDModelEngineFacade(twoDModel::robotModel::TwoDRobotMod
4141
}
4242

4343
TwoDModelEngineFacade::~TwoDModelEngineFacade(){
44+
if (mDock && !mDock->parent()) {
45+
delete mDock;
46+
}
4447
delete mView;
4548
}
4649

plugins/tools/subprogramsImporterExporter/subprogramsCollectionDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void SubprogramsCollectionDialog::accept()
8585
void SubprogramsCollectionDialog::highlightItem(QListWidgetItem *item)
8686
{
8787
if(item->checkState() == Qt::Checked) {
88-
item->setBackgroundColor(QColor("#ADFF2F"));
88+
item->setBackgroundColor(QColor(0xAD, 0xFF, 0x2F));
8989
} else {
90-
item->setBackgroundColor(QColor("#ffffff"));
90+
item->setBackgroundColor(QColorConstants::White);
9191
}
9292
}

plugins/tools/subprogramsImporterExporter/subprogramsImporterExporterPlugin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ void SubprogramsImporterExporterPlugin::exportToFile() const
125125
}
126126

127127
nameToId.remove("");
128-
QSet<qReal::Id> set(subprograms.toSet());
129128
QHash<QString, qReal::IdList> toSave;
130129
toSave.insert(fileName, nameToId.values());
131130

@@ -274,7 +273,7 @@ void SubprogramsImporterExporterPlugin::importFromCollectionTriggered() const
274273
for (const auto &metaKey : oldMeta.keys()) {
275274
mLogicalModel->mutableLogicalRepoApi().setMetaInformation(metaKey, oldMeta[metaKey]);
276275
}
277-
mProjectManager->afterOpen(mRepo->workingFile());
276+
Q_EMIT mProjectManager->afterOpen(mRepo->workingFile());
278277
mProjectManager->setUnsavedIndicator(true);
279278

280279
checkSubprogramsForUniqueNames();

plugins/tools/updatesChecker/updatesCheckerPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ UpdatesCheckerPlugin::UpdatesCheckerPlugin()
3333
, mCheckForUpdatesAction(new QAction(tr("Check for updates"), this))
3434
{
3535
mSeparator->setSeparator(true);
36-
connect(mCheckForUpdatesAction, &QAction::triggered, [this](){ checkForUpdates(); });
36+
connect(mCheckForUpdatesAction, &QAction::triggered, this, &UpdatesCheckerPlugin::checkForUpdates);
3737
}
3838

3939
QList<qReal::ActionInfo> UpdatesCheckerPlugin::actions()

qrgui/brandManager/brandManager.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ BrandManager::BrandManager()
2222
{
2323
}
2424

25-
BrandManager::~BrandManager()
26-
{
27-
delete mFonts;
28-
delete mStyles;
29-
}
30-
3125
BrandManager &BrandManager::instance()
3226
{
3327
static BrandManager instance;
@@ -41,12 +35,12 @@ void BrandManager::configure(const ToolPluginManager *toolPluginManager)
4135

4236
const Fonts *BrandManager::fonts()
4337
{
44-
return instance().mFonts;
38+
return &*instance().mFonts;
4539
}
4640

4741
const Styles *BrandManager::styles()
4842
{
49-
return instance().mStyles;
43+
return &*instance().mStyles;
5044
}
5145

5246
QString BrandManager::applicationName()

qrgui/brandManager/brandManager.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qrgui/brandManager/brandManagerDeclSpec.h"
2020
#include "qrgui/brandManager/fonts.h"
2121
#include "qrgui/brandManager/styles.h"
22+
#include <QtCore/QScopedPointer>
2223

2324
namespace qReal {
2425

@@ -50,11 +51,10 @@ class QRGUI_BRAND_MANAGER_EXPORT BrandManager
5051

5152
private:
5253
BrandManager();
53-
~BrandManager();
5454

5555
const Customizer *mCustomizer {}; // Doesn`t take ownership
56-
const Fonts *mFonts; // Takes ownership
57-
const Styles *mStyles; // Takes ownership
56+
QScopedPointer<Fonts> mFonts;
57+
QScopedPointer<Styles> mStyles;
5858
};
5959

6060
}

qrgui/mainWindow/projectManager/projectManagerWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ bool ProjectManagerWrapper::open(const QString &fileName)
108108
mMainWindow->closeStartTab();
109109
mTextManager->showInTextEditor(fileInfo, text::Languages::pickByExtension(fileInfo.suffix()));
110110
if (localActiveDiagram.isNull() && !mMainWindow->activeDiagram().isNull()) {
111-
emit afterOpen(fileName);
111+
Q_EMIT afterOpen(fileName);
112112
}
113113
}
114114

qrgui/systemFacade/components/projectManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool ProjectManager::openProject(const QString &fileName)
161161
QLOG_INFO() << "Opened project" << fileName;
162162
QLOG_DEBUG() << "Sending after open signal...";
163163

164-
emit afterOpen(fileName);
164+
Q_EMIT afterOpen(fileName);
165165

166166
return true;
167167
}

qrkernel/timeMeasurer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace qReal {
2424
/// Measures time interval between its creation and deletion, writes results to qDebug. Used for profiling.
2525
class QRKERNEL_EXPORT TimeMeasurer
2626
{
27+
Q_DISABLE_COPY_MOVE(TimeMeasurer)
2728
public:
2829
/// Constructor.
2930
/// @param methodName A name of a method or part of program to be measured.

0 commit comments

Comments
 (0)