projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for divide by zero in FixedRuler::GetPageFromPosition()
[platform/core/uifw/dali-toolkit.git]
/
base
/
dali-toolkit
/
public-api
/
controls
/
scrollable
/
scroll-view
/
scroll-view.cpp
diff --git
a/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp
b/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp
index
30e95d0
..
03f9d38
100644
(file)
--- a/
base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp
+++ b/
base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp
@@
-188,6
+188,11
@@
unsigned int DefaultRuler::GetTotalPages() const
FixedRuler::FixedRuler(float spacing)
: mSpacing(spacing)
{
FixedRuler::FixedRuler(float spacing)
: mSpacing(spacing)
{
+ if(fabsf(mSpacing) <= Math::MACHINE_EPSILON_1)
+ {
+ DALI_LOG_ERROR( "Page spacing too small (%f).", double(spacing) );
+ mSpacing = spacing >= 0.0f ? Math::MACHINE_EPSILON_1 : -Math::MACHINE_EPSILON_1;
+ }
mType = Fixed;
}
mType = Fixed;
}
@@
-203,7
+208,7
@@
float FixedRuler::GetPositionFromPage(unsigned int page, unsigned int &volume, b
volume = 0;
// spacing must be present.
volume = 0;
// spacing must be present.
- if(
mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1
)
+ if(
mEnabled
)
{
unsigned int column = page;
{
unsigned int column = page;
@@
-237,7
+242,7
@@
unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const
unsigned int page = 0;
// spacing must be present.
unsigned int page = 0;
// spacing must be present.
- if(
mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1
)
+ if(
mEnabled
)
{
if( wrap )
{
{
if( wrap )
{
@@
-248,6
+253,12
@@
unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const
if(wrap)
{
unsigned int pagesPerVolume = mDomain.GetSize() / mSpacing;
if(wrap)
{
unsigned int pagesPerVolume = mDomain.GetSize() / mSpacing;
+ // Defensive check to avoid a divide by zero below when the ruler is in an invalid state (entire domain smaller than spacing between pages of it):
+ if(pagesPerVolume < 1u)
+ {
+ pagesPerVolume = 1u;
+ DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).", mDomain.GetSize() * 1.0, mSpacing * 1.0 );
+ }
page %= pagesPerVolume;
}
}
page %= pagesPerVolume;
}
}
@@
-260,7
+271,7
@@
unsigned int FixedRuler::GetTotalPages() const
unsigned int pagesPerVolume = 1;
// spacing must be present.
unsigned int pagesPerVolume = 1;
// spacing must be present.
- if(
mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1
)
+ if(
mEnabled
)
{
pagesPerVolume = mDomain.GetSize() / mSpacing;
}
{
pagesPerVolume = mDomain.GetSize() / mSpacing;
}
@@
-541,12
+552,23
@@
void ScrollView::ScrollTo(const Vector3 &position, float duration)
GetImpl(*this).ScrollTo(position, duration);
}
GetImpl(*this).ScrollTo(position, duration);
}
+void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha)
+{
+ GetImpl(*this).ScrollTo(position, duration, alpha);
+}
+
void ScrollView::ScrollTo(const Vector3 &position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias);
}
void ScrollView::ScrollTo(const Vector3 &position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias);
}
+void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha,
+ DirectionBias horizontalBias, DirectionBias verticalBias)
+{
+ GetImpl(*this).ScrollTo(position, duration, alpha, horizontalBias, verticalBias);
+}
+
void ScrollView::ScrollTo(unsigned int page)
{
GetImpl(*this).ScrollTo(page);
void ScrollView::ScrollTo(unsigned int page)
{
GetImpl(*this).ScrollTo(page);