Commit 745e876e authored by Jan Möbius's avatar Jan Möbius
Browse files

Fixed crash with renderermanager when illegal id was given

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12858 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d061b64f
...@@ -135,9 +135,15 @@ unsigned int RenderManager::available() { ...@@ -135,9 +135,15 @@ unsigned int RenderManager::available() {
} }
void RenderManager::setActive(unsigned int _active, unsigned int _id) { void RenderManager::setActive(unsigned int _active, int _id) {
if ( _id < 0 ) {
std::cerr << "RenderManager::setActive illegal viewer id: " << _id << std::endl;
return;
}
// Increase vector size // Increase vector size
if ( _id >= activeRenderers_.size() ) if ( _id >= (int)activeRenderers_.size() )
activeRenderers_.resize(_id +1 ); activeRenderers_.resize(_id +1 );
if ( _active < availableRenderers_.size() ) if ( _active < availableRenderers_.size() )
...@@ -146,9 +152,15 @@ void RenderManager::setActive(unsigned int _active, unsigned int _id) { ...@@ -146,9 +152,15 @@ void RenderManager::setActive(unsigned int _active, unsigned int _id) {
std::cerr << "Out of range error when setting active renderer" << std::endl; std::cerr << "Out of range error when setting active renderer" << std::endl;
} }
void RenderManager::setActive(QString _active, unsigned int _id) { void RenderManager::setActive(QString _active, int _id) {
if ( _id < 0 ) {
std::cerr << "RenderManager::setActive illegal viewer id: " << _id << std::endl;
return;
}
// Increase vector size // Increase vector size
if ( _id >= activeRenderers_.size() ) if ( _id >= (int)activeRenderers_.size() )
activeRenderers_.resize(_id +1 ); activeRenderers_.resize(_id +1 );
for ( unsigned int i = 0 ; i < availableRenderers_.size() ; ++i) for ( unsigned int i = 0 ; i < availableRenderers_.size() ; ++i)
...@@ -158,17 +170,27 @@ void RenderManager::setActive(QString _active, unsigned int _id) { ...@@ -158,17 +170,27 @@ void RenderManager::setActive(QString _active, unsigned int _id) {
} }
RendererInfo* RenderManager::active(unsigned int _id) { RendererInfo* RenderManager::active( int _id) {
// Temporary viewer with no fixed id, return first renderer
if ( _id < 0 )
return 0;
// Increase vector size // Increase vector size
if ( _id >= activeRenderers_.size() ) if ( _id >= (int)activeRenderers_.size() )
activeRenderers_.resize(_id +1 ); activeRenderers_.resize(_id +1 );
return &availableRenderers_[activeRenderers_[_id]]; return &availableRenderers_[activeRenderers_[_id]];
} }
unsigned int RenderManager::activeId(unsigned int _id) { unsigned int RenderManager::activeId( int _id) {
// Temporary viewer with no fixed id, return first renderer
if ( _id < 0 )
return 0;
// Increase vector size // Increase vector size
if ( _id >= activeRenderers_.size() ) if ( _id >= (int)activeRenderers_.size() )
activeRenderers_.resize(_id +1 ); activeRenderers_.resize(_id +1 );
return activeRenderers_[_id]; return activeRenderers_[_id];
...@@ -231,7 +253,7 @@ PostProcessorInfo* PostProcessorManager::getPostProcessor(QString _name) { ...@@ -231,7 +253,7 @@ PostProcessorInfo* PostProcessorManager::getPostProcessor(QString _name) {
return 0; return 0;
} }
PostProcessorInfo* PostProcessorManager::operator[](unsigned int _id) { PostProcessorInfo* PostProcessorManager::operator[](unsigned int _id ) {
if ( _id >= availablePostProcessors_.size()) if ( _id >= availablePostProcessors_.size())
return 0; return 0;
...@@ -244,10 +266,16 @@ unsigned int PostProcessorManager::available() { ...@@ -244,10 +266,16 @@ unsigned int PostProcessorManager::available() {
return availablePostProcessors_.size(); return availablePostProcessors_.size();
} }
void PostProcessorManager::setActive(unsigned int _active, unsigned int _id) { void PostProcessorManager::setActive(unsigned int _active, int _id ) {
// Temporary viewer with no fixed id
if ( _id < 0 ) {
std::cerr << "PostProcessorManager::setActive illegal viewer id: " << _id << std::endl;
return;
}
// Increase vector size // Increase vector size
if ( _id >= activePostProcessors_.size() ) if ( _id >= (int)activePostProcessors_.size() )
activePostProcessors_.resize(_id +1 ); activePostProcessors_.resize(_id +1 );
if ( _active < availablePostProcessors_.size() ) if ( _active < availablePostProcessors_.size() )
...@@ -256,10 +284,16 @@ void PostProcessorManager::setActive(unsigned int _active, unsigned int _id) { ...@@ -256,10 +284,16 @@ void PostProcessorManager::setActive(unsigned int _active, unsigned int _id) {
std::cerr << "Out of range error when setting active post processor" << std::endl; std::cerr << "Out of range error when setting active post processor" << std::endl;
} }
void PostProcessorManager::setActive(QString _active,unsigned int _id) { void PostProcessorManager::setActive(QString _active, int _id ) {
// Temporary viewer with no fixed id
if ( _id < 0 ) {
std::cerr << "PostProcessorManager::setActive illegal viewer id: " << _id << std::endl;
return;
}
// Increase vector size // Increase vector size
if ( _id >= activePostProcessors_.size() ) if ( _id >= (int)activePostProcessors_.size() )
activePostProcessors_.resize(_id +1 ); activePostProcessors_.resize(_id +1 );
for ( unsigned int i = 0 ; i < availablePostProcessors_.size() ; ++i) for ( unsigned int i = 0 ; i < availablePostProcessors_.size() ; ++i)
...@@ -269,18 +303,28 @@ void PostProcessorManager::setActive(QString _active,unsigned int _id) { ...@@ -269,18 +303,28 @@ void PostProcessorManager::setActive(QString _active,unsigned int _id) {
} }
PostProcessorInfo* PostProcessorManager::active(unsigned int _id) { PostProcessorInfo* PostProcessorManager::active( int _id ) {
// Temporary viewer with no fixed id, return first post processor
if ( _id < 0 )
return 0;
// Increase vector size // Increase vector size
if ( _id >= activePostProcessors_.size() ) if ( _id >= (int)activePostProcessors_.size() )
activePostProcessors_.resize(_id +1 ); activePostProcessors_.resize(_id +1 );
return &availablePostProcessors_[activePostProcessors_[_id]]; return &availablePostProcessors_[activePostProcessors_[_id]];
} }
unsigned int PostProcessorManager::activeId(unsigned int _id) { unsigned int PostProcessorManager::activeId( int _id ) {
// Temporary viewer with no fixed id, return first post processor
if ( _id < 0 )
return 0;
// Increase vector size // Increase vector size
if ( _id >= activePostProcessors_.size() ) if ( _id >= (int)activePostProcessors_.size() )
activePostProcessors_.resize(_id +1 ); activePostProcessors_.resize(_id +1 );
return activePostProcessors_[_id]; return activePostProcessors_[_id];
} }
......
...@@ -130,28 +130,28 @@ class DLLEXPORT RenderManager { ...@@ -130,28 +130,28 @@ class DLLEXPORT RenderManager {
* @param _id viewer id * @param _id viewer id
* @param _active id of the renderer * @param _active id of the renderer
*/ */
void setActive(unsigned int _active, unsigned int _id); void setActive(unsigned int _active, int _id);
/** \brief set the active renderer /** \brief set the active renderer
* *
* @param _id viewer id * @param _id viewer id
* @param _active name of the renderer * @param _active name of the renderer
*/ */
void setActive(QString _active, unsigned int _id); void setActive(QString _active, int _id);
/** \brief Get the current active renderer /** \brief Get the current active renderer
* *
* @param _id viewer id * @param _id viewer id
* @return Renderer * @return Renderer
*/ */
RendererInfo* active(unsigned int _id); RendererInfo* active(int _id);
/** \brief Get the id of the active renderer /** \brief Get the id of the active renderer
* *
* @param _id viewer id * @param _id viewer id
* @return renderer id * @return renderer id
*/ */
unsigned int activeId(unsigned int _id); unsigned int activeId(int _id);
private: private:
/// Vector holding all available renderers /// Vector holding all available renderers
...@@ -235,21 +235,21 @@ class DLLEXPORT PostProcessorManager { ...@@ -235,21 +235,21 @@ class DLLEXPORT PostProcessorManager {
* @param _id viewer id * @param _id viewer id
* @param _active id of the post processor * @param _active id of the post processor
*/ */
void setActive(unsigned int _active, unsigned int _id); void setActive(unsigned int _active, int _id);
/** \brief set the active post processor for viewer /** \brief set the active post processor for viewer
* *
* @param _id viewer id * @param _id viewer id
* @param _active name of the post processor * @param _active name of the post processor
*/ */
void setActive(QString _active, unsigned int _id); void setActive(QString _active, int _id);
/** \brief Get the current active post processor for viewer /** \brief Get the current active post processor for viewer
* *
* @param _id ViewerId * @param _id ViewerId
* @return post processor * @return post processor
*/ */
PostProcessorInfo* active(unsigned int _id); PostProcessorInfo* active( int _id);
/** \brief Get the id of the active post processor for viewer /** \brief Get the id of the active post processor for viewer
...@@ -257,7 +257,7 @@ class DLLEXPORT PostProcessorManager { ...@@ -257,7 +257,7 @@ class DLLEXPORT PostProcessorManager {
* @param _id ViewerId * @param _id ViewerId
* @return post processor id * @return post processor id
*/ */
unsigned int activeId(unsigned int _id); unsigned int activeId( int _id);
private: private:
/// Vector holding all available post processors /// Vector holding all available post processors
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment