When favicon of web page is null, it would cause crash.
This patch is to add a check if pixel data is null or not.
Change-Id: If6b5f88053c2377ed4a87b6d83600cdd7f9c6746
Dali::PixelData GetImageBuffer() override
{
- uint8_t* faviconData = new uint8_t[ 16 ];
- memset(faviconData, 0xff, 16);
- return Dali::PixelData::New( faviconData, 16, 2, 2,
- Dali::Pixel::Format::RGBA8888,
- Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+ uint8_t* imageData = new uint8_t[16];
+ memset(imageData, 0xff, 16);
+ return Dali::PixelData::New(imageData, 16, 2, 2,
+ Dali::Pixel::Format::RGBA8888,
+ Dali::PixelData::ReleaseFunction::DELETE_ARRAY);
}
private:
Dali::PixelData GetFavicon() const
{
- uint8_t* faviconData = new uint8_t[ 16 ];
-
- faviconData[ 0 ] = 0xff;
- faviconData[ 1 ] = 0x00;
- faviconData[ 2 ] = 0x00;
- faviconData[ 3 ] = 0xff;
- faviconData[ 4 ] = 0xff;
- faviconData[ 5 ] = 0x00;
- faviconData[ 6 ] = 0x00;
- faviconData[ 7 ] = 0xff;
- faviconData[ 8 ] = 0xff;
- faviconData[ 9 ] = 0x00;
- faviconData[ 10 ] = 0x00;
- faviconData[ 11 ] = 0xff;
- faviconData[ 12 ] = 0xff;
- faviconData[ 13 ] = 0x00;
- faviconData[ 14 ] = 0x00;
- faviconData[ 15 ] = 0xff;
-
- return Dali::PixelData::New( faviconData, 16, 2, 2,
- Dali::Pixel::Format::RGBA8888,
- Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
+ static int testGetFaviconCount = 0;
+ if (testGetFaviconCount == 0)
+ {
+ testGetFaviconCount++;
+ uint8_t* faviconData = new uint8_t[16];
+ memset(faviconData, 0xff, 16);
+ return Dali::PixelData::New(faviconData, 16, 2, 2,
+ Dali::Pixel::Format::RGBA8888,
+ Dali::PixelData::ReleaseFunction::DELETE_ARRAY);
+ }
+ else
+ {
+ return Dali::PixelData();
+ }
}
bool CanGoForward() const
view.GetProperty( WebView::Property::TITLE ).Get( output );
DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
- // Check default value of favicon
- Dali::Toolkit::ImageView* favicon = &view.GetFavicon();
+ // Check the case that favicon is not null.
+ Dali::Toolkit::ImageView favicon = view.GetFavicon();
DALI_TEST_CHECK( favicon );
- Dali::Vector3 iconsize = favicon->GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
+ Dali::Vector3 iconsize = favicon.GetProperty< Vector3 >( Dali::Actor::Property::SIZE );
DALI_TEST_CHECK( ( int )iconsize.width == 2 && ( int )iconsize.height == 2 );
+ // Check the case that favicon is null.
+ favicon = view.GetFavicon();
+ DALI_TEST_CHECK( !favicon );
+
END_TEST;
}
return Dali::Toolkit::GetImpl(*this).GetBackForwardList();
}
-Dali::Toolkit::ImageView& WebView::GetFavicon()
+Dali::Toolkit::ImageView WebView::GetFavicon() const
{
return Dali::Toolkit::GetImpl(*this).GetFavicon();
}
Dali::Toolkit::WebBackForwardList* GetBackForwardList() const;
/**
- * @brief Get Favicon of web page.
+ * @brief Get favicon of web page.
*
- * @return Handle to a fav icon
+ * @return Handle to a favicon
*/
- Dali::Toolkit::ImageView& GetFavicon();
+ Dali::Toolkit::ImageView GetFavicon() const;
/**
* @brief Load a web page based on a given URL.
return mWebBackForwardList.get();
}
-Dali::Toolkit::ImageView& WebView::GetFavicon()
+Dali::Toolkit::ImageView WebView::GetFavicon() const
{
+ Dali::Toolkit::ImageView faviconView;
if(mWebEngine)
{
Dali::PixelData pixelData = mWebEngine.GetFavicon();
- mFaviconView = CreateImageView(pixelData);
+ faviconView = CreateImageView(pixelData);
}
- return mFaviconView;
+ return faviconView;
}
void WebView::LoadUrl(const std::string& url)
}
}
-Dali::Toolkit::ImageView WebView::CreateImageView(Dali::PixelData pixel)
+Dali::Toolkit::ImageView WebView::CreateImageView(Dali::PixelData pixel) const
{
+ if(!pixel)
+ {
+ return Dali::Toolkit::ImageView();
+ }
+
std::string url = Dali::Toolkit::Image::GenerateUrl(pixel);
Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url);
imageView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixel.GetWidth(), pixel.GetHeight()));
/**
* @copydoc Dali::Toolkit::WebView::GetFavicon()
*/
- Dali::Toolkit::ImageView& GetFavicon();
+ Dali::Toolkit::ImageView GetFavicon() const;
/**
* @copydoc Dali::Toolkit::WebView::LoadUrl()
* @param[in] pixel Pixel data
* @return The new image view
*/
- Dali::Toolkit::ImageView CreateImageView(Dali::PixelData pixel);
+ Dali::Toolkit::ImageView CreateImageView(Dali::PixelData pixel) const;
/**
* @brief Callback function to be called when page load started.
std::unique_ptr<Dali::Toolkit::WebSettings> mWebSettings;
std::unique_ptr<Dali::Toolkit::WebBackForwardList> mWebBackForwardList;
- Dali::Toolkit::ImageView mFaviconView;
-
Dali::PropertyNotification mPositionUpdateNotification;
Dali::PropertyNotification mSizeUpdateNotification;
Dali::PropertyNotification mScaleUpdateNotification;