|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Fwd: bug in nShaderParams::Clear ?Calling Clear() on an array releases the memory and more memory is
allocated for new elements to be added. Resetting shader params looks like something that can happen often, so doing this is not a good idea. Manually invalidating the reference would be better. By the way, remember that the nref<nTexture2> arguments are soft references, therefore the refcount for the texture is not incremented. ZHANG Zikai wrote: > hi, > > in nebula2\code\nebula2\inc\gfx2\nshaderparams.h > the function nShaderParams::Clear() may cause crash: > > inline > void > nShaderParams::Clear() > { > int i; > for (i = 0; i < nShaderState::NumParameters; i++) > { > this->paramIndex[i] = -1; > } > this->paramArray.Reset(); > } > > the paramArray is defined like this > > nArray<ParamAndArg> paramArray; > > nArray::Reset() only set the numElements to 0, it will not call destructor. > Thus ParamAndArg::arg which contains a nRef<nTexture2> tex will not be > destroyed correctly, and referenecd count of the nTexture2 will go > wrong. > > luckyly, the nArray free its elements at its destructor and calls the > ~nRef, the symptom will not show up then. > > better change the nShaderParams::Clear() to > inline > void > nShaderParams::Clear() > { > int i; > for (i = 0; i < nShaderState::NumParameters; i++) > { > this->paramIndex[i] = -1; > } > this->paramArray.Clear(); > } > > and use a corrected nArray. I'll send a nArray patch to pangu. -- maGarcias | tragnarionStudios lists@... ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV *** NOTE: To reply to the list use "reply to all", *** *** to reply direct to the sender use "reply" *** _______________________________________________ Nebuladevice-discuss mailing list Nebuladevice-discuss@... https://lists.sourceforge.net/lists/listinfo/nebuladevice-discuss |
| Free embeddable forum powered by Nabble | Forum Help |