summaryrefslogtreecommitdiff
path: root/src/newgrf_config.h
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-26 21:48:28 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-27 18:30:56 +0200
commitdb54e208256958f721bf74bf058b45039be5b488 (patch)
treee1d74970d7f56e9ddc3be53562a86b33ab714635 /src/newgrf_config.h
parent9197de39e4bf4c17ba6da82c2ed1b858603a443a (diff)
downloadopenttd-db54e208256958f721bf74bf058b45039be5b488.tar.xz
Change: mark copy-assignment as deleted for classes with a copy-constructor that is not trivial
This to prevent the default copy-assignment getting used when during the assignment also some other memory needs to be allocated as that would otherwise be freed.
Diffstat (limited to 'src/newgrf_config.h')
-rw-r--r--src/newgrf_config.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/newgrf_config.h b/src/newgrf_config.h
index ef7128905..1588f8c3a 100644
--- a/src/newgrf_config.h
+++ b/src/newgrf_config.h
@@ -113,6 +113,9 @@ struct GRFError {
GRFError(StringID severity, StringID message = 0);
GRFError(const GRFError &error);
+ /* Remove the copy assignment, as the default implementation will not do the right thing. */
+ GRFError &operator=(GRFError &rhs) = delete;
+
std::string custom_message; ///< Custom message (if present)
std::string data; ///< Additional data for message and custom_message
StringID message; ///< Default message
@@ -154,6 +157,9 @@ struct GRFConfig : ZeroedMemoryAllocator {
GRFConfig(const GRFConfig &config);
~GRFConfig();
+ /* Remove the copy assignment, as the default implementation will not do the right thing. */
+ GRFConfig &operator=(GRFConfig &rhs) = delete;
+
GRFIdentifier ident; ///< grfid and md5sum to uniquely identify newgrfs
uint8 original_md5sum[16]; ///< MD5 checksum of original file if only a 'compatible' file was loaded
char *filename; ///< Filename - either with or without full path