Commits

Anonymous committed 82c4808

Make sure to not use floaters of different type than LLPreview as LLPreview instance.

  • Participants
  • Parent commits 1388163

Comments (0)

Files changed (1)

File indra/newview/llpreview.cpp

 
 void LLMultiPreview::onOpen(const LLSD& key)
 {
-	LLPreview* frontmost_preview = (LLPreview*)mTabContainer->getCurrentPanel();
+	// Floater could be something else than LLPreview, eg LLFloaterProfile.
+	LLPreview* frontmost_preview = dynamic_cast<LLPreview*>(mTabContainer->getCurrentPanel());
+
 	if (frontmost_preview && frontmost_preview->getAssetStatus() == LLPreview::PREVIEW_ASSET_UNLOADED)
 	{
 		frontmost_preview->loadAsset();
 {
 	if(new_rect.getWidth() != getRect().getWidth() || new_rect.getHeight() != getRect().getHeight())
 	{
-		LLPreview* frontmost_preview = (LLPreview*)mTabContainer->getCurrentPanel();
-		if (frontmost_preview) frontmost_preview->userResized();
+		// Floater could be something else than LLPreview, eg LLFloaterProfile.
+		LLPreview* frontmost_preview = dynamic_cast<LLPreview*>(mTabContainer->getCurrentPanel());
+
+		if (frontmost_preview)
+		{
+			frontmost_preview->userResized();
+		}
 	}
 	LLFloater::handleReshape(new_rect, by_user);
 }
 
 void LLMultiPreview::tabOpen(LLFloater* opened_floater, bool from_click)
 {
-	LLPreview* opened_preview = (LLPreview*)opened_floater;
+	// Floater could be something else than LLPreview, eg LLFloaterProfile.
+	LLPreview* opened_preview = dynamic_cast<LLPreview*>(opened_floater);
+
 	if (opened_preview && opened_preview->getAssetStatus() == LLPreview::PREVIEW_ASSET_UNLOADED)
 	{
 		opened_preview->loadAsset();