From a5e4b15b7d29a64781eb32ef71e557a5bb8dc870 Mon Sep 17 00:00:00 2001
From: Seth ProductEngine <slitovchuk@productengine.com>
Date: Thu, 23 Feb 2012 21:02:46 +0200
Subject: [PATCH] Linux build fix. Moved type casts from protected base classes
 to derived LLCoord.

---
 indra/llmath/llcoord.h      | 19 +++++++++++++------
 indra/llui/llfloater.cpp    |  4 ++--
 indra/llwindow/llwindow.cpp |  8 ++++----
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h
index 756e23dbdf4..9b76268afde 100644
--- a/indra/llmath/llcoord.h
+++ b/indra/llmath/llcoord.h
@@ -26,6 +26,15 @@
 #ifndef LL_LLCOORD_H
 #define LL_LLCOORD_H
 
+template<typename> class LLCoord;
+struct LL_COORD_TYPE_GL;
+struct LL_COORD_TYPE_WINDOW;
+struct LL_COORD_TYPE_SCREEN;
+
+typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL;
+typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
+typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
+
 struct LLCoordCommon
 {
 	LLCoordCommon(S32 x, S32 y) : mX(x), mY(y) {}
@@ -62,6 +71,8 @@ class LLCoord : protected COORD_FRAME
 	bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; }
 	bool operator!=(const self_t& other) const { return !(*this == other); }
 
+	static const self_t& getTypedCoords(const COORD_FRAME& self) { return static_cast<const self_t&>(self); }
+	static self_t& getTypedCoords(COORD_FRAME& self) { return static_cast<self_t&>(self); }
 };
 
 struct LL_COORD_TYPE_GL 
@@ -70,13 +81,13 @@ struct LL_COORD_TYPE_GL
 
 	LLCoordCommon convertToCommon() const
 	{
-		const LLCoord<LL_COORD_TYPE_GL>& self = static_cast<const LLCoord<LL_COORD_TYPE_GL>&>(*this);
+		const LLCoordGL& self = LLCoordGL::getTypedCoords(*this);
 		return LLCoordCommon(self.mX, self.mY);
 	}
 
 	void convertFromCommon(const LLCoordCommon& from)
 	{
-		LLCoord<LL_COORD_TYPE_GL>& self = static_cast<LLCoord<LL_COORD_TYPE_GL>&>(*this);
+		LLCoordGL& self = LLCoordGL::getTypedCoords(*this);
 		self.mX = from.mX;
 		self.mY = from.mY;
 	}
@@ -98,8 +109,4 @@ struct LL_COORD_TYPE_SCREEN
 	void convertFromCommon(const LLCoordCommon& from);
 };
 
-typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL;
-typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
-typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
-
 #endif
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 3afa1b8e3ad..2a40bbf33cf 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -3306,7 +3306,7 @@ bool LLCoordFloater::operator==(const LLCoordFloater& other) const
 
 LLCoordCommon LL_COORD_FLOATER::convertToCommon() const
 {
-	const LLCoordFloater& self = static_cast<const LLCoordFloater&>(*this);
+	const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
 
 	LLRect snap_rect = gFloaterView->getSnapRect();
 	LLFloater* floaterp = mFloater.get();
@@ -3348,7 +3348,7 @@ LLCoordCommon LL_COORD_FLOATER::convertToCommon() const
 
 void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from)
 {
-	LLCoordFloater& self = static_cast<LLCoordFloater&>(*this);
+	LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
 	LLRect snap_rect = gFloaterView->getSnapRect();
 	LLFloater* floaterp = mFloater.get();
 	S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index 6834b34387c..4e91271d833 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -440,7 +440,7 @@ BOOL LLWindowManager::isWindowValid(LLWindow *window)
 //coordinate conversion utility funcs that forward to llwindow
 LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const
 {
-	const LLCoordWindow& self = static_cast<const LLCoordWindow&>(*this);
+	const LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this);
 
 	LLWindow* windowp = &(*LLWindow::beginInstances());
 	LLCoordGL out;
@@ -450,7 +450,7 @@ LLCoordCommon LL_COORD_TYPE_WINDOW::convertToCommon() const
 
 void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from)
 {
-	LLCoordWindow& self = static_cast<LLCoordWindow&>(*this);
+	LLCoordWindow& self = LLCoordWindow::getTypedCoords(*this);
 
 	LLWindow* windowp = &(*LLWindow::beginInstances());
 	LLCoordGL from_gl(from);
@@ -459,7 +459,7 @@ void LL_COORD_TYPE_WINDOW::convertFromCommon(const LLCoordCommon& from)
 
 LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const
 {
-	const LLCoordScreen& self = static_cast<const LLCoordScreen&>(*this);
+	const LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this);
 
 	LLWindow* windowp = &(*LLWindow::beginInstances());
 	LLCoordGL out;
@@ -469,7 +469,7 @@ LLCoordCommon LL_COORD_TYPE_SCREEN::convertToCommon() const
 
 void LL_COORD_TYPE_SCREEN::convertFromCommon(const LLCoordCommon& from)
 {
-	LLCoordScreen& self = static_cast<LLCoordScreen&>(*this);
+	LLCoordScreen& self = LLCoordScreen::getTypedCoords(*this);
 
 	LLWindow* windowp = &(*LLWindow::beginInstances());
 	LLCoordGL from_gl(from);
-- 
GitLab