mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Fixed another smart pointer bug (assignment operator copied ref count);
Fixed symbol editor grid git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@385 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -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);
|
||||
|
||||
+13
-20
@@ -160,7 +160,15 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
template <typename T> 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<T*>(this);
|
||||
}
|
||||
private:
|
||||
AtomicInt ref_count;
|
||||
template <typename T> friend void intrusive_ptr_add_ref(IntrusivePtrBase*);
|
||||
@@ -172,7 +180,7 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
}
|
||||
template <typename T> inline void intrusive_ptr_release(IntrusivePtrBase<T>* p) {
|
||||
if (--p->ref_count == 0) {
|
||||
delete static_cast<T*>(p);
|
||||
static_cast<T*>(p)->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,32 +195,17 @@ inline shared_ptr<T> 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<IntrusivePtrBaseWithDelete> {
|
||||
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 <typename T> friend void intrusive_ptr_release(IntrusivePtrBase<T>*);
|
||||
};
|
||||
|
||||
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<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
virtual ~IntrusivePtrVirtualBase() {}
|
||||
};
|
||||
|
||||
class IntrusivePtrBaseWithDelete {
|
||||
class IntrusivePtrBaseWithDelete : public IntrusivePtrBase<IntrusivePtrBaseWithDelete> {
|
||||
public:
|
||||
virtual ~IntrusivePtrBaseWithDelete() {}
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user