1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:17:45 +00:00

SpaceAnalyzer: Make TreeMapWidget responsible for filesystem analysis

Also, the Tree object was only ever used by the TreeMapWidget, so its
creation can happen inside `analyze()`, fixing the memory leak issue.
Plus, it doesn't have to be RefCounted.
This commit is contained in:
Sam Atkins 2023-02-03 14:00:00 +00:00 committed by Andreas Kling
parent 98e9ee07e3
commit 1ec59cc52a
4 changed files with 82 additions and 93 deletions

View file

@ -9,7 +9,6 @@
#include <AK/DeprecatedString.h>
#include <AK/Forward.h>
#include <AK/OwnPtr.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
struct MountInfo {
@ -44,16 +43,21 @@ private:
OwnPtr<Vector<TreeNode>> m_children;
};
class Tree : public RefCounted<Tree> {
class Tree {
public:
Tree(DeprecatedString root_name)
: m_root(move(root_name)) {};
static ErrorOr<NonnullOwnPtr<Tree>> create(DeprecatedString root_name)
{
return adopt_nonnull_own_or_enomem(new (nothrow) Tree(move(root_name)));
}
~Tree() {};
TreeNode& root()
{
return m_root;
};
private:
Tree(DeprecatedString root_name)
: m_root(move(root_name)) {};
TreeNode m_root;
};