diff options
| author | 2023-11-05 18:56:43 +0000 | |
|---|---|---|
| committer | 2023-11-05 18:56:43 +0000 | |
| commit | 83f01b36a11734fd91a4e7aad99c15463858fe4a (patch) | |
| tree | 519c72e52ce009884ff47995e021db458110935d /include | |
| parent | Apply SVSHOLDs to already existing users. (diff) | |
When copying a message also copy the source string.
Diffstat (limited to 'include')
| -rw-r--r-- | include/clientprotocol.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h index c606dd670..d686cd947 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -92,8 +92,10 @@ class CoreExport ClientProtocol::TagSelection class CoreExport ClientProtocol::MessageSource { + protected: User* sourceuser; const std::string* sourcestr; + bool sourceowned:1; public: /** Constructor, sets the source to be the full host of a user or sets it to be nothing. @@ -102,10 +104,17 @@ class CoreExport ClientProtocol::MessageSource * Optional, defaults to NULL. */ MessageSource(User* Sourceuser = NULL) + : sourceowned(false) { SetSourceUser(Sourceuser); } + ~MessageSource() + { + if (sourceowned && sourcestr) + delete sourcestr; + } + /** Constructor, sets the source to the supplied string and optionally sets the source user. * @param Sourcestr String to use as message source for serialization purposes. Must remain valid * as long as this object is alive. @@ -114,6 +123,7 @@ class CoreExport ClientProtocol::MessageSource * Useful when the source string is synthesized but it is still related to a User. */ MessageSource(const std::string& Sourcestr, User* Sourceuser = NULL) + : sourceowned(false) { SetSource(Sourcestr, Sourceuser); } @@ -451,6 +461,12 @@ class CoreExport ClientProtocol::Message : public ClientProtocol::MessageSource if (!curr.IsOwned()) ReplaceParam(j, curr); } + + if (GetSource()) + { + sourcestr = new std::string(*GetSource()); + sourceowned = true; + } } void SetSideEffect(bool Sideeffect) { sideeffect = Sideeffect; } |
