Skip to content

Commit

Permalink
[cleanup] Use std::unique_ptr for Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Oct 15, 2024
1 parent ef7b702 commit c758bd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 5 additions & 4 deletions include/guisan/widgets/tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
#ifndef GCN_TAB_HPP
#define GCN_TAB_HPP

#include <map>
#include <string>

#include "guisan/mouselistener.hpp"
#include "guisan/platform.hpp"
#include "guisan/widget.hpp"

#include <map>
#include <memory>
#include <string>

namespace gcn
{
class Label;
Expand Down Expand Up @@ -144,7 +145,7 @@ namespace gcn
/**
* Holds the label of the tab.
*/
Label* mLabel = nullptr;
std::unique_ptr<Label> mLabel;

/**
* Holds the tabbed area the tab is a part of.
Expand Down
9 changes: 3 additions & 6 deletions src/widgets/tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,16 @@

namespace gcn
{
Tab::Tab() : mLabel(new Label())
Tab::Tab() : mLabel(std::make_unique<Label>())
{
mLabel->setPosition(6, 6);
add(mLabel);
add(mLabel.get());
setFrameSize(1);

addMouseListener(this);
}

Tab::~Tab()
{
delete mLabel;
}
Tab::~Tab() = default;

void Tab::adjustSize()
{
Expand Down

0 comments on commit c758bd4

Please sign in to comment.