summaryrefslogtreecommitdiffstats
path: root/qtools/qcstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'qtools/qcstring.h')
-rw-r--r--qtools/qcstring.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/qtools/qcstring.h b/qtools/qcstring.h
index 7170455..5c3a0de 100644
--- a/qtools/qcstring.h
+++ b/qtools/qcstring.h
@@ -498,19 +498,22 @@ public:
}
StringRep &operator=(const StringRep &s)
{
- if (!u.s.isShort)
- {
- u.l.d->dispose();
- }
- if (s.u.s.isShort) // copy by value
- {
- u.s = s.u.s;
- }
- else // copy by reference
+ if (&s!=this)
{
- u.l.isShort=FALSE;
- u.l.d = s.u.l.d;
- u.l.d->refCount++;
+ if (!u.s.isShort)
+ {
+ u.l.d->dispose();
+ }
+ if (s.u.s.isShort) // copy by value
+ {
+ u.s = s.u.s;
+ }
+ else // copy by reference
+ {
+ u.l.isShort=FALSE;
+ u.l.d = s.u.l.d;
+ u.l.d->refCount++;
+ }
}
return *this;
}