diff --git a/src/gui/symbol/control.cpp b/src/gui/symbol/control.cpp index 938777c9..94b4ed21 100644 --- a/src/gui/symbol/control.cpp +++ b/src/gui/symbol/control.cpp @@ -150,9 +150,9 @@ void SymbolControl::draw(DC& dc) { // draw grid if (settings.symbol_grid) { wxSize s = dc.GetSize(); - int lines = settings.symbol_grid_size; + double lines = settings.symbol_grid_size; for (int i = 0 ; i <= lines ; ++i) { - int x = (int) rotation.trS(i/lines-0.0001); + int x = floor(rotation.trS(i/lines-0.0001)); //dc.SetPen(Color(0, i%5 == 0 ? 64 : 31, 0)); //dc.SetPen(Color(i%5 == 0 ? 64 : 31, 0, 0)); dc.SetLogicalFunction(wxAND); diff --git a/src/util/smart_ptr.hpp b/src/util/smart_ptr.hpp index 98fa7873..cd418731 100644 --- a/src/util/smart_ptr.hpp +++ b/src/util/smart_ptr.hpp @@ -160,7 +160,15 @@ inline shared_ptr new_shared9(const A0& a0, const A1& a1, const A2& a2, const template class IntrusivePtrBase { public: inline IntrusivePtrBase() : ref_count(0) {} - inline IntrusivePtrBase(const IntrusivePtrBase&) : ref_count(0) {} // don't copy construct the reference count! + // don't copy construct the reference count! + inline IntrusivePtrBase(const IntrusivePtrBase&) : ref_count(0) {} + // don't assign the reference count! + inline void operator = (const IntrusivePtrBase&) { } + protected: + /// Delete this object, can be overloaded + inline void destroy() { + delete static_cast(this); + } private: AtomicInt ref_count; template friend void intrusive_ptr_add_ref(IntrusivePtrBase*); @@ -172,7 +180,7 @@ inline shared_ptr new_shared9(const A0& a0, const A1& a1, const A2& a2, const } template inline void intrusive_ptr_release(IntrusivePtrBase* p) { if (--p->ref_count == 0) { - delete static_cast(p); + static_cast(p)->destroy(); } } @@ -187,32 +195,17 @@ inline shared_ptr new_shared9(const A0& a0, const A1& a1, const A2& a2, const // ----------------------------------------------------------------------------- : Intrusive pointer base : with delete /// Base class for objects wishing to use intrusive_ptrs, using a manual delete function - class IntrusivePtrBaseWithDelete { + class IntrusivePtrBaseWithDelete : public IntrusivePtrBase { public: - inline IntrusivePtrBaseWithDelete() : ref_count(0) {} - inline IntrusivePtrBaseWithDelete(const IntrusivePtrBaseWithDelete&) - : ref_count(0) {} // don't copy construct the reference count! virtual ~IntrusivePtrBaseWithDelete() {} protected: /// Delete this object virtual void destroy() { delete this; } - private: - AtomicInt ref_count; - friend void intrusive_ptr_add_ref(IntrusivePtrBaseWithDelete*); - friend void intrusive_ptr_release(IntrusivePtrBaseWithDelete*); + template friend void intrusive_ptr_release(IntrusivePtrBase*); }; - inline void intrusive_ptr_add_ref(IntrusivePtrBaseWithDelete* p) { - ++p->ref_count; - } - inline void intrusive_ptr_release(IntrusivePtrBaseWithDelete* p) { - if (--p->ref_count == 0) { - p->destroy(); - } - } - #else #define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE #define intrusive_ptr shared_ptr @@ -235,7 +228,7 @@ inline shared_ptr new_shared9(const A0& a0, const A1& a1, const A2& a2, const virtual ~IntrusivePtrVirtualBase() {} }; - class IntrusivePtrBaseWithDelete { + class IntrusivePtrBaseWithDelete : public IntrusivePtrBase { public: virtual ~IntrusivePtrBaseWithDelete() {} protected: