[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.2/kdelibs/kdecore/date
From:       David Jarvie <software () astrojar ! org ! uk>
Date:       2009-03-25 22:02:43
Message-ID: 1238018563.297854.21285.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 944661 by djarvie:

Don't copy instance to itself in operator=()


 M  +11 -7     kdatetime.cpp  


--- branches/KDE/4.2/kdelibs/kdecore/date/kdatetime.cpp #944660:944661
@@ -1,6 +1,6 @@
 /*
     This file is part of the KDE libraries
-    Copyright (c) 2005-2008 David Jarvie <djarvie@kde.org>
+    Copyright (c) 2005-2009 David Jarvie <djarvie@kde.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -143,11 +143,14 @@
 
 KDateTime::Spec &KDateTime::Spec::operator=(const Spec& spec)
 {
-    d->type = spec.d->type;
-    if (d->type == KDateTime::TimeZone)
-        d->tz = spec.d->tz;
-    else if (d->type == KDateTime::OffsetFromUTC)
-        d->utcOffset = spec.d->utcOffset;
+    if (&spec != this)
+    {
+        d->type = spec.d->type;
+        if (d->type == KDateTime::TimeZone)
+            d->tz = spec.d->tz;
+        else if (d->type == KDateTime::OffsetFromUTC)
+            d->utcOffset = spec.d->utcOffset;
+    }
     return *this;
 }
 
@@ -816,7 +819,8 @@
 
 KDateTime &KDateTime::operator=(const KDateTime &other)
 {
-    d = other.d;
+    if (&other != this)
+        d = other.d;
     return *this;
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic