delete copy constructors and assignment operators explicitly

This commit is contained in:
Garux 2021-03-24 15:48:29 +03:00
parent 6aa8e432f7
commit dc5dea6d21
10 changed files with 39 additions and 37 deletions

View File

@ -289,10 +289,10 @@ private:
void size_decrement(){ void size_decrement(){
--m_size; --m_size;
} }
HashTable( const HashTable& other );
HashTable& operator=( const HashTable& other );
public: public:
HashTable( const HashTable& other ) = delete; // not copyable
HashTable& operator=( const HashTable& other ) = delete; // not assignable
HashTable() : m_bucketCount( 0 ), m_buckets( 0 ), m_size( 0 ){ HashTable() : m_bucketCount( 0 ), m_buckets( 0 ), m_size( 0 ){
initialise(); initialise();
} }

View File

@ -81,9 +81,6 @@ class ToggleShown
{ {
bool m_shownDeferred; bool m_shownDeferred;
ToggleShown( const ToggleShown& other ); // NOT COPYABLE
ToggleShown& operator=( const ToggleShown& other ); // NOT ASSIGNABLE
static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){ static gboolean notify_visible( GtkWidget* widget, gpointer dummy, ToggleShown* self ){
/* destroy = notify::visible with visible = 0, thus let's filter it out */ /* destroy = notify::visible with visible = 0, thus let's filter it out */
if( gtk_main_level() > 0 ){ //== 0 at destroy time if( gtk_main_level() > 0 ){ //== 0 at destroy time
@ -103,6 +100,9 @@ public:
GtkWidget* m_widget; GtkWidget* m_widget;
ToggleItem m_item; ToggleItem m_item;
ToggleShown( const ToggleShown& other ) = delete; // NOT COPYABLE
ToggleShown& operator=( const ToggleShown& other ) = delete; // NOT ASSIGNABLE
ToggleShown( bool shown ) ToggleShown( bool shown )
: m_shownDeferred( shown ), m_widget( 0 ), m_item( ActiveCaller( *this ) ){ : m_shownDeferred( shown ), m_widget( 0 ), m_item( ActiveCaller( *this ) ){
} }

View File

@ -34,12 +34,13 @@ struct RGBAPixel
class RGBAImage : public Image class RGBAImage : public Image
{ {
RGBAImage( const RGBAImage& other );
RGBAImage& operator=( const RGBAImage& other );
public: public:
RGBAPixel* pixels; RGBAPixel* pixels;
unsigned int width, height; unsigned int width, height;
RGBAImage( const RGBAImage& other ) = delete; // not copyable
RGBAImage& operator=( const RGBAImage& other ) = delete; // not assignable
RGBAImage( unsigned int _width, unsigned int _height ) RGBAImage( unsigned int _width, unsigned int _height )
: pixels( new RGBAPixel[_width * _height] ), width( _width ), height( _height ){ : pixels( new RGBAPixel[_width * _height] ), width( _width ), height( _height ){
} }

View File

@ -40,9 +40,6 @@ class ModelSkinKey : public ModuleObserver
ModelSkin* m_skin; ModelSkin* m_skin;
Callback m_skinChangedCallback; Callback m_skinChangedCallback;
ModelSkinKey( const ModelSkinKey& );
ModelSkinKey operator=( const ModelSkinKey& );
void construct(){ void construct(){
m_skin = &GlobalModelSkinCache().capture( m_name.c_str() ); m_skin = &GlobalModelSkinCache().capture( m_name.c_str() );
m_skin->attach( *this ); m_skin->attach( *this );
@ -53,6 +50,9 @@ class ModelSkinKey : public ModuleObserver
} }
public: public:
ModelSkinKey( const ModelSkinKey& ) = delete; // not copyable
ModelSkinKey operator=( const ModelSkinKey& ) = delete; // not assignable
ModelSkinKey( const Callback& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){ ModelSkinKey( const Callback& skinChangedCallback ) : m_skinChangedCallback( skinChangedCallback ){
construct(); construct();
} }

View File

@ -55,8 +55,6 @@ class NameKeys : public Entity::Observer, public Namespaced
Namespace* m_namespace; Namespace* m_namespace;
EntityKeyValues& m_entity; EntityKeyValues& m_entity;
KeyIsNameFunc m_keyIsName; KeyIsNameFunc m_keyIsName;
NameKeys( const NameKeys& other );
NameKeys& operator=( const NameKeys& other );
typedef std::map<CopiedString, EntityKeyValue*> KeyValues; typedef std::map<CopiedString, EntityKeyValue*> KeyValues;
KeyValues m_keyValues; KeyValues m_keyValues;
@ -86,6 +84,9 @@ class NameKeys : public Entity::Observer, public Namespaced
} }
} }
public: public:
NameKeys( const NameKeys& other ) = delete; // not copyable
NameKeys& operator=( const NameKeys& other ) = delete; // not assignable
NameKeys( EntityKeyValues& entity ) : m_namespace( 0 ), m_entity( entity ), m_keyIsName( Static<KeyIsName>::instance().m_keyIsName ){ NameKeys( EntityKeyValues& entity ) : m_namespace( 0 ), m_entity( entity ), m_keyIsName( Static<KeyIsName>::instance().m_keyIsName ){
m_entity.attach( *this ); m_entity.attach( *this );
} }

View File

@ -453,9 +453,6 @@ class PicoModelInstance :
}; };
typedef Array<Remap> SurfaceRemaps; typedef Array<Remap> SurfaceRemaps;
SurfaceRemaps m_skins; SurfaceRemaps m_skins;
PicoModelInstance( const PicoModelInstance& );
PicoModelInstance operator=( const PicoModelInstance& );
public: public:
typedef LazyStatic<TypeCasts> StaticTypeCasts; typedef LazyStatic<TypeCasts> StaticTypeCasts;
@ -508,6 +505,9 @@ public:
constructRemaps(); constructRemaps();
} }
PicoModelInstance( const PicoModelInstance& ) = delete; // not copyable
PicoModelInstance operator=( const PicoModelInstance& ) = delete; // not assignable
PicoModelInstance( const scene::Path& path, scene::Instance* parent, PicoModel& picomodel ) : PicoModelInstance( const scene::Path& path, scene::Instance* parent, PicoModel& picomodel ) :
Instance( path, parent, this, StaticTypeCasts::instance().get() ), Instance( path, parent, this, StaticTypeCasts::instance().get() ),
m_picomodel( picomodel ), m_picomodel( picomodel ),

View File

@ -378,7 +378,7 @@ public:
releaseShader(); releaseShader();
} }
// copy-construction not supported // copy-construction not supported
FaceShader( const FaceShader& other ); FaceShader( const FaceShader& other ) = delete;
void instanceAttach(){ void instanceAttach(){
m_instanced = true; m_instanced = true;
@ -487,10 +487,6 @@ public:
class FaceTexdef : public FaceShaderObserver class FaceTexdef : public FaceShaderObserver
{ {
// not copyable
FaceTexdef( const FaceTexdef& other );
// not assignable
FaceTexdef& operator=( const FaceTexdef& other );
public: public:
class SavedState class SavedState
{ {
@ -511,6 +507,11 @@ public:
bool m_projectionInitialised; bool m_projectionInitialised;
bool m_scaleApplied; bool m_scaleApplied;
// not copyable
FaceTexdef( const FaceTexdef& other ) = delete;
// not assignable
FaceTexdef& operator=( const FaceTexdef& other ) = delete;
FaceTexdef( FaceTexdef(
FaceShader& shader, FaceShader& shader,
const TextureProjection& projection, const TextureProjection& projection,
@ -958,13 +959,13 @@ private:
UndoObserver* m_undoable_observer; UndoObserver* m_undoable_observer;
MapFile* m_map; MapFile* m_map;
// assignment not supported
Face& operator=( const Face& other );
// copy-construction not supported
Face( const Face& other );
public: public:
// assignment not supported
Face& operator=( const Face& other ) = delete;
// copy-construction not supported
Face( const Face& other ) = delete;
Face( FaceObserver* observer ) : Face( FaceObserver* observer ) :
m_refcount( 0 ), m_refcount( 0 ),
m_shader( texdef_name_default() ), m_shader( texdef_name_default() ),
@ -1704,7 +1705,7 @@ public:
} }
// assignment not supported // assignment not supported
Brush& operator=( const Brush& other ); Brush& operator=( const Brush& other ) = delete;
void setDoom3GroupOrigin( const Vector3& origin ){ void setDoom3GroupOrigin( const Vector3& origin ){
//globalOutputStream() << "func_static origin before: " << m_funcStaticOrigin << " after: " << origin << "\n"; //globalOutputStream() << "func_static origin before: " << m_funcStaticOrigin << " after: " << origin << "\n";
@ -3425,9 +3426,6 @@ class BrushInstance :
const LightList* m_lightList; const LightList* m_lightList;
BrushTransformModifier m_transform; BrushTransformModifier m_transform;
BrushInstance( const BrushInstance& other ); // NOT COPYABLE
BrushInstance& operator=( const BrushInstance& other ); // NOT ASSIGNABLE
public: public:
static Counter* m_counter; static Counter* m_counter;
@ -3440,6 +3438,9 @@ public:
STRING_CONSTANT( Name, "BrushInstance" ); STRING_CONSTANT( Name, "BrushInstance" );
BrushInstance( const BrushInstance& other ) = delete; // NOT COPYABLE
BrushInstance& operator=( const BrushInstance& other ) = delete; // NOT ASSIGNABLE
BrushInstance( const scene::Path& path, scene::Instance* parent, Brush& brush ) : BrushInstance( const scene::Path& path, scene::Instance* parent, Brush& brush ) :
Instance( path, parent, this, StaticTypeCasts::instance().get() ), Instance( path, parent, this, StaticTypeCasts::instance().get() ),
m_brush( brush ), m_brush( brush ),

View File

@ -120,12 +120,12 @@ void setGridPower( GridPower power );
class GridMenuItem class GridMenuItem
{ {
GridPower m_id; GridPower m_id;
GridMenuItem( const GridMenuItem& other ); // NOT COPYABLE
GridMenuItem& operator=( const GridMenuItem& other ); // NOT ASSIGNABLE
public: public:
ToggleItem m_item; ToggleItem m_item;
GridMenuItem( const GridMenuItem& other ) = delete; // NOT COPYABLE
GridMenuItem& operator=( const GridMenuItem& other ) = delete; // NOT ASSIGNABLE
GridMenuItem( GridPower id ) : m_id( id ), m_item( ExportCaller( *this ) ){ GridMenuItem( GridPower id ) : m_id( id ), m_item( ExportCaller( *this ) ){
} }
void set(){ void set(){

View File

@ -97,8 +97,6 @@ class NameObserver
m_names.erase( name_read( c_str() ) ); m_names.erase( name_read( c_str() ) );
} }
} }
NameObserver& operator=( const NameObserver& other );
public: public:
NameObserver( UniqueNames& names ) : m_names( names ){ NameObserver( UniqueNames& names ) : m_names( names ){
construct(); construct();
@ -106,6 +104,7 @@ public:
NameObserver( const NameObserver& other ) : m_names( other.m_names ), m_name( other.m_name ){ NameObserver( const NameObserver& other ) : m_names( other.m_names ), m_name( other.m_name ){
construct(); construct();
} }
NameObserver& operator=( const NameObserver& other ) = delete; // not assignable
~NameObserver(){ ~NameObserver(){
destroy(); destroy();
} }

View File

@ -351,9 +351,9 @@ struct ModelResource : public Resource
ASSERT_MESSAGE( !realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted( m_name.c_str() ) ); ASSERT_MESSAGE( !realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted( m_name.c_str() ) );
} }
// NOT COPYABLE // NOT COPYABLE
ModelResource( const ModelResource& ); ModelResource( const ModelResource& ) = delete;
// NOT ASSIGNABLE // NOT ASSIGNABLE
ModelResource& operator=( const ModelResource& ); ModelResource& operator=( const ModelResource& ) = delete;
void setModel( const NodeSmartReference& model ){ void setModel( const NodeSmartReference& model ){
m_model = model; m_model = model;