MAINT-3585 FIXED Viewer Crashes when attempting to upload image.

The bug was fixed, the reasone of crash is following. The Core Flow view
contain another GL context and will not care about restoring a previous.
I restore context manually.
This path also contain a minor changes in another files.

All changes described here.

Сhange's for fix current bug.
indra/llwindow/llwindow.h
indra/llwindow/llwindowheadless.h
indra/llwindow/llwindowmacosx.h
indra/llwindow/llwindowsdl.h
indra/llwindow/llwindowwin32.h
indra/newview/lllocalbitmaps.cpp
indra/newview/llviewerdisplay.cpp
indra/newview/llviewerdisplay.h

Twice mUsage initialization (replace to forward initialization).
indra/llcharacter/lljointstate.h

Looks like condition should be befor memcopy call, otherwise - possible CRASH.
indra/llcommon/llmd5.cpp

Unused condition and variables.
indra/llmath/llsphere.cpp

Looks like should be under if otherwise - possible CRASH
indra\llprimitive\llmodel.cpp

Useless assert's.
indra/llrender/llrender.cpp
indra/newview/lldaycyclemanager.cpp
master
ruslantproductengine 2014-11-03 20:05:20 +02:00
parent f3d73d9e72
commit 799d13269a
17 changed files with 66 additions and 39 deletions

View File

@ -64,22 +64,18 @@ protected:
public:
// Constructor
LLJointState()
{
mUsage = 0;
mJoint = NULL;
mUsage = 0;
mWeight = 0.f;
mPriority = LLJoint::USE_MOTION_PRIORITY;
}
: mUsage(0)
, mJoint(NULL)
, mWeight(0.f)
, mPriority(LLJoint::USE_MOTION_PRIORITY)
{}
LLJointState(LLJoint* joint)
{
mUsage = 0;
mJoint = joint;
mUsage = 0;
mWeight = 0.f;
mPriority = LLJoint::USE_MOTION_PRIORITY;
}
: mUsage(0)
, mJoint(joint)
, mWeight(0.f)
, mPriority(LLJoint::USE_MOTION_PRIORITY)
{}
// joint that this state is applied to
LLJoint* getJoint() { return mJoint; }

View File

@ -118,6 +118,12 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
buffer_space = 64 - buffer_index; // how much space is left in buffer
// now, transform each 64-byte piece of the input, bypassing the buffer
if (input == NULL || input_length == 0){
std::cerr << "LLMD5::update: Invalid input!" << std::endl;
return;
}
// Transform as many times as possible.
if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
// fill the rest of the buffer and transform
@ -127,12 +133,6 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) {
buffer_space);
transform (buffer);
// now, transform each 64-byte piece of the input, bypassing the buffer
if (input == NULL || input_length == 0){
std::cerr << "LLMD5::update: Invalid input!" << std::endl;
return;
}
for (input_index = buffer_space; input_index + 63 < input_length;
input_index += 64)
transform (input+input_index);

View File

@ -248,8 +248,8 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list)
// compute the starting step-size
F32 minimum_radius = 0.5f * llmin(diagonal.mV[VX], llmin(diagonal.mV[VY], diagonal.mV[VZ]));
F32 step_length = bounding_radius - minimum_radius;
S32 step_count = 0;
S32 max_step_count = 12;
//S32 step_count = 0;
//S32 max_step_count = 12;
F32 half_milimeter = 0.0005f;
// wander the center around in search of tighter solutions
@ -258,7 +258,7 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list)
S32 last_dz = 2;
while (step_length > half_milimeter
&& step_count < max_step_count)
/*&& step_count < max_step_count*/)
{
// the algorithm for testing the maximum radius could be expensive enough
// that it makes sense to NOT duplicate testing when possible, so we keep

View File

@ -1681,11 +1681,11 @@ LLSD LLModel::writeModel(
}
}
F32* src_tc = (F32*) face.mTexCoords[j].mV;
//texcoord
if (face.mTexCoords)
{
F32* src_tc = (F32*) face.mTexCoords[j].mV;
for (U32 k = 0; k < 2; ++k)
{ //for each component
//convert to 16-bit normalized

View File

@ -53,7 +53,7 @@ bool LLRender::sGLCoreProfile = false;
static const U32 LL_NUM_TEXTURE_LAYERS = 32;
static const U32 LL_NUM_LIGHT_UNITS = 8;
static GLenum sGLTextureType[] =
static const GLenum sGLTextureType[] =
{
GL_TEXTURE_2D,
GL_TEXTURE_RECTANGLE_ARB,
@ -61,14 +61,14 @@ static GLenum sGLTextureType[] =
GL_TEXTURE_2D_MULTISAMPLE
};
static GLint sGLAddressMode[] =
static const GLint sGLAddressMode[] =
{
GL_REPEAT,
GL_MIRRORED_REPEAT,
GL_CLAMP_TO_EDGE
};
static GLenum sGLCompareFunc[] =
static const GLenum sGLCompareFunc[] =
{
GL_NEVER,
GL_ALWAYS,
@ -82,7 +82,7 @@ static GLenum sGLCompareFunc[] =
const U32 immediate_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD0;
static GLenum sGLBlendFactor[] =
static const GLenum sGLBlendFactor[] =
{
GL_ONE,
GL_ZERO,
@ -99,12 +99,12 @@ static GLenum sGLBlendFactor[] =
};
LLTexUnit::LLTexUnit(S32 index)
: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT),
mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT),
mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR),
mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
mHasMipMaps(false)
: mCurrTexType(TT_NONE), mCurrBlendType(TB_MULT),
mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT),
mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR),
mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA),
mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
mHasMipMaps(false)
{
llassert_always(index < (S32)LL_NUM_TEXTURE_LAYERS);
mIndex = index;
@ -1189,7 +1189,7 @@ void LLRender::syncMatrices()
if (shader)
{
llassert(shader);
//llassert(shader);
bool mvp_done = false;
@ -1288,7 +1288,7 @@ void LLRender::syncMatrices()
}
else if (!LLGLSLShader::sNoFixedFunction)
{
GLenum mode[] =
static const GLenum mode[] =
{
GL_MODELVIEW,
GL_PROJECTION,

View File

@ -122,6 +122,7 @@ public:
virtual void gatherInput() = 0;
virtual void delayInputProcessing() = 0;
virtual void swapBuffers() = 0;
virtual void restoreGLContext() = 0;
virtual void bringToFront() = 0;
virtual void focusClient() { }; // this may not have meaning or be required on other platforms, therefore, it's not abstract
virtual void setOldResize(bool oldresize) { };

View File

@ -52,3 +52,6 @@ void LLWindowHeadless::swapBuffers()
{
}
void LLWindowHeadless::restoreGLContext()
{
}

View File

@ -74,8 +74,10 @@ public:
/*virtual*/ void gatherInput() {};
/*virtual*/ void delayInputProcessing() {};
/*virtual*/ void swapBuffers();
/*virtual*/ void restoreGLContext();
// handy coordinate space conversion routines
// handy coordinate space conversion routines
/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; };
/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordScreen *to) { return FALSE; };
/*virtual*/ BOOL convertCoords(LLCoordWindow from, LLCoordGL *to) { return FALSE; };

View File

@ -901,6 +901,11 @@ void LLWindowMacOSX::swapBuffers()
CGLFlushDrawable(mContext);
}
void LLWindowMacOSX::restoreGLContext()
{
CGLSetCurrentContext(mContext);
}
F32 LLWindowMacOSX::getGamma()
{
F32 result = 2.2; // Default to something sane

View File

@ -87,6 +87,8 @@ public:
/*virtual*/ void gatherInput();
/*virtual*/ void delayInputProcessing() {};
/*virtual*/ void swapBuffers();
/*virtual*/ void restoreGLContext();
// handy coordinate space conversion routines
/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);

View File

@ -77,6 +77,7 @@ public:
/*virtual*/ void gatherInput() {};
/*virtual*/ void delayInputProcessing() {};
/*virtual*/ void swapBuffers();
/*virtual*/ void restoreGLContext() {};
// handy coordinate space conversion routines
/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to) { return FALSE; };

View File

@ -97,6 +97,7 @@ public:
/*virtual*/ void processMiscNativeEvents();
/*virtual*/ void gatherInput();
/*virtual*/ void swapBuffers();
/*virtual*/ void restoreGLContext() {};
/*virtual*/ void delayInputProcessing() { };

View File

@ -83,6 +83,7 @@ public:
/*virtual*/ void gatherInput();
/*virtual*/ void delayInputProcessing();
/*virtual*/ void swapBuffers();
/*virtual*/ void restoreGLContext() {};
// handy coordinate space conversion routines
/*virtual*/ BOOL convertCoords(LLCoordScreen from, LLCoordWindow *to);

View File

@ -207,7 +207,7 @@ bool LLDayCycleManager::addPreset(const std::string& name, const LLSD& data)
{
if (name.empty())
{
llassert(name.empty());
//llassert(name.empty());
return false;
}

View File

@ -64,6 +64,8 @@
#include "llimagedimensionsinfo.h"
#include "llviewercontrol.h"
#include "lltrans.h"
#include "llviewerdisplay.h"
/*=======================================*/
/* Formal declarations, constants, etc. */
/*=======================================*/
@ -842,6 +844,9 @@ bool LLLocalBitmapMgr::addUnit()
LLFilePicker& picker = LLFilePicker::instance();
if (picker.getMultipleOpenFiles(LLFilePicker::FFLOAD_IMAGE))
{
//For fix problem with Core Flow view on OSX
restoreGLContext();
sTimer.stopTimer();
std::string filename = picker.getFirstFile();

View File

@ -1344,6 +1344,14 @@ void swap()
gDisplaySwapBuffers = TRUE;
}
void restoreGLContext()
{
if(gViewerWindow && gViewerWindow->getWindow())
{
gViewerWindow->getWindow()->restoreGLContext();
}
}
void renderCoordinateAxes()
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);

View File

@ -34,6 +34,8 @@ void display_cleanup();
void display(BOOL rebuild = TRUE, F32 zoom_factor = 1.f, int subfield = 0, BOOL for_snapshot = FALSE);
void restoreGLContext();
extern BOOL gDisplaySwapBuffers;
extern BOOL gDepthDirty;
extern BOOL gTeleportDisplay;