Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing memory leaks #11658

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ApplicationLibCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ RiaApplication::RiaApplication()

m_commandRouter = std::make_unique<RimCommandRouter>();
m_osduConnector = nullptr;
m_sumoConnector = nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -184,6 +185,16 @@ RiaApplication::~RiaApplication()
RiaFontCache::clear();

caf::SelectionManager::instance()->setPdmRootObject( nullptr );

m_project.reset();

delete m_osduConnector.data();
m_osduConnector.clear();
m_osduConnector = nullptr;

delete m_sumoConnector.data();
m_sumoConnector.clear();
m_sumoConnector = nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions ApplicationLibCode/Application/RiaGuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ RiaGuiApplication::RiaGuiApplication( int& argc, char** argv )
//--------------------------------------------------------------------------------------------------
RiaGuiApplication::~RiaGuiApplication()
{
delete m_mainWindow.data();
m_mainWindow.clear();

m_mainPlotWindow.reset();
}

//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifRftSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ std::set<int> RifRftSegment::uniqueOneBasedBranchIndices( RiaDefines::RftBranchT
{
std::set<int> indices;

for ( const auto [branchId, branchIndex] : m_oneBasedBranchIndexMap )
for ( const auto& [branchId, branchIndex] : m_oneBasedBranchIndexMap )
{
indices.insert( branchIndex );
}
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/ProjectDataModel/Rim3dView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Rim3dView::Rim3dView()
// Every timer tick, send a signal for updating animations.
// Any animation is supposed to connect to this signal
// in order to having only one central animation driver.
m_animationTimer = std::make_unique<QTimer>( new QTimer() );
m_animationTimer = std::make_unique<QTimer>();
m_animationTimer->setInterval( m_animationIntervalMillisec );
QObject::connect( m_animationTimer.get(), &QTimer::timeout, [this]() { updateAnimations.send(); } );
}
Expand Down
13 changes: 11 additions & 2 deletions ApplicationLibCode/UserInterface/RiuWellLogPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent )
: RiuMultiPlotPage( plotDefinition, parent )
{
m_verticalTrackScrollBar = new QScrollBar( nullptr );
m_verticalTrackScrollBar = new QScrollBar( this );
m_verticalTrackScrollBar->setOrientation( Qt::Vertical );
m_verticalTrackScrollBar->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );

Expand All @@ -27,7 +27,7 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* pare

connect( m_verticalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );

m_horizontalTrackScrollBar = new QScrollBar( nullptr );
m_horizontalTrackScrollBar = new QScrollBar( this );
m_horizontalTrackScrollBar->setOrientation( Qt::Horizontal );
m_horizontalTrackScrollBar->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );

Expand All @@ -37,6 +37,15 @@ RiuWellLogPlot::RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* pare
connect( m_horizontalTrackScrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuWellLogPlot::~RiuWellLogPlot()
{
delete m_horizontalTrackScrollBarLayout.data();
delete m_verticalTrackScrollBarLayout.data();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ApplicationLibCode/UserInterface/RiuWellLogPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RiuWellLogPlot : public RiuMultiPlotPage
Q_OBJECT
public:
RiuWellLogPlot( RimDepthTrackPlot* plotDefinition, QWidget* parent );
~RiuWellLogPlot() override;

RimViewWindow* ownerViewWindow() const override;

Expand Down
6 changes: 5 additions & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiTreeEditorHandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class PdmUiTreeEditorHandle : public PdmUiEditorHandle
{
public:
PdmUiTreeEditorHandle() {}
~PdmUiTreeEditorHandle() override {}
~PdmUiTreeEditorHandle() override
{
delete m_widget.data();
m_widget.clear();
}

QWidget* getOrCreateWidget( QWidget* parent );
QWidget* widget() { return m_widget; }
Expand Down
6 changes: 5 additions & 1 deletion Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,19 @@ class PdmUiTreeViewWidget : public QTreeView
explicit PdmUiTreeViewWidget( QWidget* parent = nullptr )
: QTreeView( parent )
{
setStyle( new PdmUiTreeViewStyle );
m_style = std::make_shared<PdmUiTreeViewStyle>();
setStyle( m_style.get() );
};

~PdmUiTreeViewWidget() override{};

bool isTreeItemEditWidgetActive() const { return state() == QAbstractItemView::EditingState; }

protected:
void dragMoveEvent( QDragMoveEvent* event ) override;
void dragLeaveEvent( QDragLeaveEvent* event ) override;

std::shared_ptr<PdmUiTreeViewStyle> m_style;
};

//--------------------------------------------------------------------------------------------------
Expand Down