Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

add destructor method #50

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions Adafruit_Thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ Adafruit_Thermal::Adafruit_Thermal(Stream *s, uint8_t dtr)
dtrEnabled = false;
}

// Destructor
Adafruit_Thermal::~Adafruit_Thermal(){
if (stream != nullptr) {
delete stream;
}
}

// This method sets the estimated completion time for a just-issued task.
void Adafruit_Thermal::timeoutSet(unsigned long x) {
if (!dtrEnabled)
Expand Down
4 changes: 3 additions & 1 deletion Adafruit_Thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class Adafruit_Thermal : public Print {
* @param dtr Data Terminal Ready control
*/
Adafruit_Thermal(Stream *s = &Serial, uint8_t dtr = 255);

~Adafruit_Thermal();

size_t
/*!
Expand Down Expand Up @@ -337,7 +339,7 @@ class Adafruit_Thermal : public Print {
hasPaper();

private:
Stream *stream;
Stream *stream = nullptr;
uint8_t printMode,
prevByte, // Last character issued to printer
column, // Last horizontal column printed
Expand Down