Fix more double release in QTimeZone on Mac

Several objects are released without being retained.
This causes double free crash.

Task-number: QTBUG-37582
Task-number: QTBUG-35890
Change-Id: Ic64419c22ab555ba77ada1864feaff247798d3ad
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Jean-Philippe Proulx 2014-04-30 13:01:36 -04:00 committed by The Qt Project
parent 8605f44097
commit d17e48108d

View File

@ -142,7 +142,6 @@ QString QMacTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
NSString *macLocaleCode = QCFString::toNSString(locale.name()); NSString *macLocaleCode = QCFString::toNSString(locale.name());
NSLocale *macLocale = [[NSLocale alloc] initWithLocaleIdentifier:macLocaleCode]; NSLocale *macLocale = [[NSLocale alloc] initWithLocaleIdentifier:macLocaleCode];
const QString result = QCFString::toQString([m_nstz localizedName:style locale:macLocale]); const QString result = QCFString::toQString([m_nstz localizedName:style locale:macLocale]);
[macLocaleCode release];
[macLocale release]; [macLocale release];
return result; return result;
} }
@ -192,7 +191,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons
data.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:date]; data.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:date];
data.standardTimeOffset = data.offsetFromUtc - data.daylightTimeOffset; data.standardTimeOffset = data.offsetFromUtc - data.daylightTimeOffset;
data.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:date]); data.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:date]);
[date release];
return data; return data;
} }
@ -203,8 +201,6 @@ bool QMacTimeZonePrivate::hasTransitions() const
NSDate *epoch = [NSDate dateWithTimeIntervalSince1970:0]; NSDate *epoch = [NSDate dateWithTimeIntervalSince1970:0];
const NSDate *date = [m_nstz nextDaylightSavingTimeTransitionAfterDate:epoch]; const NSDate *date = [m_nstz nextDaylightSavingTimeTransitionAfterDate:epoch];
const bool result = ([date timeIntervalSince1970] > [epoch timeIntervalSince1970]); const bool result = ([date timeIntervalSince1970] > [epoch timeIntervalSince1970]);
[epoch release];
[date release];
return result; return result;
} }
@ -224,7 +220,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc
tran.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:nextDate]; tran.daylightTimeOffset = [m_nstz daylightSavingTimeOffsetForDate:nextDate];
tran.standardTimeOffset = tran.offsetFromUtc - tran.daylightTimeOffset; tran.standardTimeOffset = tran.offsetFromUtc - tran.daylightTimeOffset;
tran.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:nextDate]); tran.abbreviation = QCFString::toQString([m_nstz abbreviationForDate:nextDate]);
[nextDate release];
return tran; return tran;
} }
@ -246,7 +241,6 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate]; nextDate = [m_nstz nextDaylightSavingTimeTransitionAfterDate:nextDate];
nextSecs = [nextDate timeIntervalSince1970]; nextSecs = [nextDate timeIntervalSince1970];
} }
[nextDate release];
} }
if (secsList.size() >= 1) if (secsList.size() >= 1)
return data(qint64(secsList.last()) * 1000); return data(qint64(secsList.last()) * 1000);