Properly free associated clients of an lc::Session instance on its end

remotes/origin/HEAD
markuspg 8 years ago
parent 2898ff9132
commit 4c1fb49264

@ -146,7 +146,8 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
}
}
try {
sessionsModel->push_back( new Session{ argzTreeDataTargetPath,
sessionsModel->push_back( new Session{ std::move( argAssocCl ),
argzTreeDataTargetPath,
argzTreePort, argzTreeVersion,
argPrintLocalReceipts,
argParticipNameReplacement,

@ -24,13 +24,15 @@
extern std::unique_ptr< lc::Settings > settings;
lc::Session::Session( const QString &argZTreeDataTargetPath, const quint16 argZTreePort,
lc::Session::Session( QVector< Client* > &&argAssocClients,
const QString &argZTreeDataTargetPath, const quint16 argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, QObject *argParent ):
QObject{ argParent },
zTreePort{ argZTreePort },
anonymousReceiptsPlaceholder{ argAnonymousReceiptsPlaceholder },
assocClients{ std::move( argAssocClients ) },
latexHeaderName{ argLatexHeaderName },
printReceiptsForLocalClients{ argPrintReceiptsForLocalClients },
zTreeDataTargetPath{ argZTreeDataTargetPath },
@ -53,8 +55,11 @@ lc::Session::Session( const QString &argZTreeDataTargetPath, const quint16 argZT
}
lc::Session::~Session() {
for ( auto &client : assocClients ) {
client->SetSessionPort( 0 );
client->SetzLeafVersion( "" );
}
delete receiptsHandler;
delete zTreeInstance;
}
QVariant lc::Session::GetDataItem( int argIndex ) {

@ -28,6 +28,8 @@
namespace lc {
class Client;
//! A class containing an entire session.
/*!
This class represents an entire session with its zTree instance and the corresponding lcReceiptsHandler instance.
@ -38,8 +40,9 @@ class Session : public QObject {
public:
const int zTreePort = 7000; //! The port this session's zTree instance is running on
Session( const QString &argZTreeDataTargetPath, const quint16 argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
Session( QVector< Client* > &&argAssocClients, const QString &argZTreeDataTargetPath,
const quint16 argZTreePort, const QString &argZTreeVersionPath,
bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, QObject *argParent = nullptr );
~Session();
@ -67,6 +70,7 @@ private slots:
private:
const QString anonymousReceiptsPlaceholder; //! Placeholder which shall be inserted for participant names if anonymous printing is desired (QString != "")
const QVector< Client* > assocClients;
const QString latexHeaderName; //! The name of the chosen LaTeX header
const bool printReceiptsForLocalClients = true; //! True if receipts shall be printed for local clients
ReceiptsHandler *receiptsHandler = nullptr; //! For automatic creation and printing of the receipts

Loading…
Cancel
Save