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

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

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

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

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

Loading…
Cancel
Save