[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepimlibs/kcal
From: Sergio Luis Martins <iamsergio () gmail ! com>
Date: 2010-05-26 14:23:49
Message-ID: 20100526142349.13BC2AC8C2 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1130828 by smartins:
Don't allow hierarchy loops between incidences. An incidence can't be an ancestor of it's parent.
Fixes a hang.
M +18 -0 calendar.cpp
M +8 -0 calendar.h
--- trunk/KDE/kdepimlibs/kcal/calendar.cpp #1130827:1130828
@@ -972,8 +972,15 @@
Incidence *parent = incidence( forincidence->relatedToUid() );
if ( parent ) {
// Found it
+
+ // look for hierarchy loops
+ if ( isAncestorOf( forincidence, parent ) ) {
+ kWarning() << "hierarchy loop beetween " << forincidence->uid() << " and " << parent->uid();
+ } else {
forincidence->setRelatedTo( parent );
parent->addRelation( forincidence );
+ }
+
} else {
// Not found, put this in the mOrphans list
// Note that the mOrphans dict might contain multiple entries with the
@@ -1064,6 +1071,17 @@
incidence->setRelatedTo( 0 );
}
+bool Calendar::isAncestorOf( Incidence *ancestor, Incidence *incidence )
+{
+ if ( !incidence || incidence->relatedToUid().isEmpty() ) {
+ return false;
+ } else if ( incidence->relatedToUid() == ancestor->uid() ) {
+ return true;
+ } else {
+ return isAncestorOf( ancestor, this->incidence( incidence->relatedToUid() ) );
+ }
+}
+
void Calendar::CalendarObserver::calendarModified( bool modified, Calendar *calendar )
{
Q_UNUSED( modified );
--- trunk/KDE/kdepimlibs/kcal/calendar.h #1130827:1130828
@@ -912,6 +912,14 @@
*/
virtual void removeRelations( Incidence *incidence );
+ /**
+ Checks if @p ancestor is an ancestor of @p incidence
+
+ @param ancestor the incidence we are testing to be an ancestor
+ @param incidence the incidence we are testing to be descended from @p ancestor
+ */
+ bool isAncestorOf( Incidence *ancestor, Incidence *incidence );
+
// Filter Specific Methods //
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic