Commits

Christian Fischer  committed 8465de1

renamed safe_release into clear_ref to match the functions intention

  • Participants
  • Parent commits 1da83c3

Comments (0)

Files changed (36)

File src/android/wiesel/android/io/android_asset_fs.cpp

 }
 
 AndroidAssetFileSystem::~AndroidAssetFileSystem() {
-	safe_release(root);
+	clear_ref(root);
 	return;
 }
 

File src/android/wiesel/android/video/android_video_driver.cpp

 	}
 
 	// release the render context
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	// check if the screen was released correctly
 	assert(display == EGL_NO_DISPLAY);
 	}
 
 	// remove the old context, if any
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	// initialize the new render context
 	render_context = keep(new AndroidGlRenderContext(getScreen()));
 
 bool AndroidVideoDeviceDriver::releaseContext() {
 	// release the render context
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	if (display != EGL_NO_DISPLAY) {
 		eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

File src/base/wiesel/util/shared_object.h

 
 	/**
 	 * @brief Takes a pointer of a \ref SharedObject to release it.
-	 * When the pointer is \ref NULL, nothing happens.
-	 * The pointer will be set to \ref NULL after releasing the object.
+	 * When the pointer is \c NULL, nothing happens.
+	 * The pointer will be set to \c NULL after releasing the object.
 	 */
 	template <class OBJ>
-	inline void safe_release(OBJ*& obj) {
+	inline void clear_ref(OBJ*& obj) {
 		if (obj != NULL) {
 			_release(obj);
 			obj  = NULL;
 		}
 
 		~ref() {
-			safe_release(pointer);
+			clear_ref(pointer);
 		}
 		
 	public:
 		inline const ref<T> operator=(T* p) {
 			if (this->pointer != p) {
-				safe_release(this->pointer);
+				clear_ref(this->pointer);
 				this->pointer = keep(p);
 			}
 
 
 		inline const ref<T> operator=(const ref<T>& other) {
 			if (this->pointer != other.pointer) {
-				safe_release(this->pointer);
+				clear_ref(this->pointer);
 				this->pointer = keep(other.pointer);
 			}
 

File src/base/wiesel/util/thread.cpp

 		}
 	#endif
 
-	safe_release(runnable);
+	clear_ref(runnable);
 
 	return;
 }

File src/common/wiesel/io/generic_root_fs.cpp

 }
 
 GenericFileSystem::~GenericFileSystem() {
-	safe_release(root);
+	clear_ref(root);
 	return;
 }
 

File src/common/wiesel/util/libxml_sax_parser.cpp

 
 	// parser cleanup
 	parser->finish();
-	safe_release(parser);
+	clear_ref(parser);
 
 	// libxml cleanup
 	xmlCleanupParser();
 
 		// parser cleanup
 		parser->finish();
-		safe_release(parser);
+		clear_ref(parser);
 
 		// libxml cleanup
 		xmlCleanupParser();

File src/common/wiesel/util/tinyxml2_parser.cpp

 	}
 
 	virtual ~LibTinyXml2ParserVisitor() {
-		safe_release(parser);
+		clear_ref(parser);
 	}
 
 public:

File src/core/wiesel/engine.cpp

 Engine::~Engine() {
 	shutdown();
 
-	safe_release(mainthread);
+	clear_ref(mainthread);
 
 	return;
 }
 
 	// release the application object
 	application->onShutdown();
-	safe_release(application);
+	clear_ref(application);
 
 	return;
 }

File src/core/wiesel/graph/2d/multisprite_node.cpp

 
 
 MultiSpriteNode::~MultiSpriteNode() {
-	safe_release(vbo);
+	clear_ref(vbo);
 
 	setTexture(NULL);
 	clear();
 
 
 void MultiSpriteNode::setTexture(Texture* texture) {
-	safe_release(this->texture);
+	clear_ref(this->texture);
 
 	if (texture) {
 		this->texture = keep(texture);

File src/core/wiesel/graph/2d/sprite_node.cpp

 
 
 SpriteNode::~SpriteNode() {
-	safe_release(vbo);
+	clear_ref(vbo);
 
 	setTexture(NULL);
 	setShader(NULL);
 
 
 void SpriteNode::setTexture(Texture* texture) {
-	safe_release(this->texture);
+	clear_ref(this->texture);
 
 	if (texture) {
 		this->texture = keep(texture);
 	}
 
 	// reset current sprite, when texture was set manually
-	safe_release(this->sprite);
+	clear_ref(this->sprite);
 
 	// need to update the vertex buffer
 	vbo_dirty = true;
 void SpriteNode::setSpriteFrame(SpriteFrame* sprite) {
 	if (this->sprite != sprite) {
 		if (this->sprite) {
-			safe_release(this->sprite);
+			clear_ref(this->sprite);
 			this->setTexture(NULL);
 		}
 

File src/core/wiesel/io/datasource.cpp

 }
 
 BufferDataSource::~BufferDataSource() {
-	safe_release(buffer);
+	clear_ref(buffer);
 }
 
 DataBuffer *BufferDataSource::getDataBuffer() {

File src/core/wiesel/io/directory.cpp

 
 Directory::~Directory() {
 	// release parent directory
-	safe_release(parent);
+	clear_ref(parent);
 	return;
 }
 

File src/core/wiesel/io/directory_filesystem.cpp

 }
 
 DirectoryFileSystem::~DirectoryFileSystem() {
-	safe_release(root);
-	safe_release(enclosed_root);
+	clear_ref(root);
+	clear_ref(enclosed_root);
 	return;
 }
 
 }
 
 DirectoryFileSystemDirectory::~DirectoryFileSystemDirectory() {
-	safe_release(enclosed_directory);
+	clear_ref(enclosed_directory);
 	return;
 }
 
 }
 
 DirectoryFileSystemFile::~DirectoryFileSystemFile() {
-	safe_release(enclosed_file);
+	clear_ref(enclosed_file);
 	return;
 }
 

File src/core/wiesel/io/file.cpp

 }
 
 File::~File() {
-	safe_release(parent);
+	clear_ref(parent);
 	return;
 }
 
 }
 
 FileDataSource::~FileDataSource() {
-	safe_release(file);
-	safe_release(content);
+	clear_ref(file);
+	clear_ref(content);
 }
 
 DataBuffer *FileDataSource::getDataBuffer() {
 }
 
 void FileDataSource::releaseDataBuffer() {
-	safe_release(content);
+	clear_ref(content);
 }
 
 File *FileDataSource::getFile() {

File src/core/wiesel/module_registry.h

 		 * but the module loader will create a new instance next time calling \ref create().
 		 */
 		virtual void release() {
-			safe_release(instance);
+			clear_ref(instance);
 		}
 
 	private:

File src/core/wiesel/resources/graphics/image.cpp

 
 
 Image::~Image() {
-	safe_release(pixel_data);
+	clear_ref(pixel_data);
 }
 
 
 	assert(new_image_size == data->getSize());
 
 	if (new_image_size == data->getSize()) {
-		safe_release(this->pixel_data);
+		clear_ref(this->pixel_data);
 
 		this->pixel_data   = keep(data);
 		this->pixel_format = format;

File src/core/wiesel/resources/graphics/spriteframe.cpp

 }
 
 SpriteFrame::~SpriteFrame() {
-	safe_release(texture);
+	clear_ref(texture);
 }
 
 

File src/core/wiesel/resources/graphics/spritesheet.cpp

 SpriteSheet::~SpriteSheet() {
 	clear();
 
-	safe_release(texture);
+	clear_ref(texture);
 
 	return;
 }

File src/core/wiesel/ui/bitmapfont.cpp

 
 void BitmapFont::setSpriteSheet(SpriteSheet* ss) {
 	if (ss != this->spritesheet) {
-		safe_release(this->spritesheet);
+		clear_ref(this->spritesheet);
 
 		if (ss) {
 			this->spritesheet = keep(ss);
 
 void BitmapFont::setShader(video::Shader* shader) {
 	if (shader != this->shader) {
-		safe_release(this->shader);
+		clear_ref(this->shader);
 
 		if (shader) {
 			this->shader = keep(shader);

File src/core/wiesel/ui/label_node.cpp

 
 void LabelNode::setFont(Font* font) {
 	if (this->font != font) {
-		safe_release(this->font);
+		clear_ref(this->font);
 
 		if (font) {
 			this->font = keep(font);

File src/core/wiesel/ui/touch.cpp

 }
 
 Touch::~Touch() {
-	safe_release(owner);
-	safe_release(node);
+	clear_ref(owner);
+	clear_ref(node);
 	return;
 }
 

File src/core/wiesel/util/xml_parser.cpp

 XmlParser::~XmlParser() {
 	assert(state == NULL); // parsing was not finished?
 
-	safe_release(callback);
-	safe_release(state);
+	clear_ref(callback);
+	clear_ref(state);
 
 	return;
 }
 	assert(state == NULL); // last parsing was not finished?
 
 	if (state) {
-		safe_release(state);
+		clear_ref(state);
 	}
 
 	state = new XmlDocumentState();
 			callback->onDocumentFinished(state);
 		}
 
-		safe_release(state);
+		clear_ref(state);
 	}
 
 	return;

File src/core/wiesel/video/render_buffer.cpp

 
 	if (target_textures[index].texture != texture) {
 		if (target_textures[index].texture) {
-			safe_release(target_textures[index].texture);
+			clear_ref(target_textures[index].texture);
 		}
 
 		if (texture) {
 void RenderBuffer::clearTextures() {
 	for(TextureList::iterator it=target_textures.begin(); it!=target_textures.end(); ++it) {
 		if (it->texture) {
-			safe_release(it->texture);
+			clear_ref(it->texture);
 		}
 	}
 

File src/core/wiesel/video/render_context.cpp

 			release(renderbuffer_stack.top());
 			renderbuffer_stack.pop();
 
-			safe_release(active_renderbuffer);
+			clear_ref(active_renderbuffer);
 		}
 
 		// when there are still renderbuffers available, enable the top one

File src/core/wiesel/video/screen.cpp

 
 Screen::~Screen() {
 	setVideoDeviceDriver(NULL);
-	safe_release(touch_handler);
+	clear_ref(touch_handler);
 
 	return;
 }

File src/core/wiesel/video/shader_target.cpp

 
 void ShaderTarget::setShader(Shader* shader) {
 	if (this->shader != shader) {
-		safe_release(this->shader);
+		clear_ref(this->shader);
 
 		if (shader) {
 			this->shader = shader;

File src/core/wiesel/video/texture.cpp

 }
 
 Texture::~Texture() {
-	safe_release(data);
+	clear_ref(data);
 	return;
 }
 

File src/directx11/wiesel/dx11/video/dx11_render_context.cpp

 void DirectX11RenderContext::setShader(Shader* shader) {
 	if (this->active_shader != shader) {
 		// clear the old shader
-		safe_release(this->active_shader);
+		clear_ref(this->active_shader);
 
 		// ... and it's implementation
-		safe_release(this->active_shader_content);
+		clear_ref(this->active_shader_content);
 
 		// store the new shader
 		if (shader) {
 		Dx11TextureContent *active_texture_content = this->active_textures_content[index];
 
 		// clear the old texture
-		safe_release(active_texture);
+		clear_ref(active_texture);
 
 		// and it's implementation
-		safe_release(active_texture_content);
+		clear_ref(active_texture_content);
 
 		// store the new texture
 		if (texture) {

File src/directx11/wiesel/dx11/video/dx11_video_driver.cpp

 Dx11VideoDeviceDriver::~Dx11VideoDeviceDriver() {
 	Engine::getInstance()->unregisterUpdateable(this);
 
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	return;
 }
 
 bool Dx11VideoDeviceDriver::initDirectX() {
 	// remove the old context, if any
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	// initialize the new render context
 	render_context = keep(DirectX11RenderContext::createContextWithWindowHandle(hWnd, getScreen(), &info));

File src/net/wiesel/io/net/connection.cpp

 	}
 
 	virtual ~CreateConnectionAsyncTask() {
-		safe_release(listener);
+		clear_ref(listener);
 	}
 
 	virtual void run() {

File src/net/wiesel/io/net/message_dispatcher.cpp

 }
 
 MessageDispatcher::~MessageDispatcher() {
-	safe_release(connection);
-	safe_release(thread);
+	clear_ref(connection);
+	clear_ref(thread);
 }
 
 
 			);
 
 			// release the object (we're creating a new one)
-			safe_release(connection);
+			clear_ref(connection);
 
 			// stop here, when no reconnect-flag is set
 			if (!hasFlag(AutoReconnect)) {
 	current_thread->lock();
 
 	if (this->thread) {
-		safe_release(this->thread);
+		clear_ref(this->thread);
 	}
 
 	if (connection) {
 		connection->disconnect();
-		safe_release(connection);
+		clear_ref(connection);
 	}
 
 	if (current_thread) {

File src/opengl/wiesel/video/gl/gl_render_context.cpp

 void OpenGlRenderContext::setShader(Shader* shader) {
 	if (this->active_shader != shader) {
 		// clear the old shader
-		safe_release(this->active_shader);
+		clear_ref(this->active_shader);
 
 		// ... and it's implementation
-		safe_release(this->active_shader_content);
+		clear_ref(this->active_shader_content);
 
 		// store the new shader
 		if (shader) {
 		GlTextureContent *active_texture_content = this->active_textures_content[index];
 
 		// clear the old texture
-		safe_release(active_texture);
+		clear_ref(active_texture);
 
 		// and it's implementation
-		safe_release(active_texture_content);
+		clear_ref(active_texture_content);
 
 		// store the new texture
 		if (texture) {

File src/sdl/wiesel/sdl/video/sdl_video_driver.cpp

 		platform->removeReceiver(this);
 	}
 	
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	return;
 }
 	}
 
 	// remove the old context, if any
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	// initialize the new render context
 	render_context = keep(new SdlGlRenderContext(getScreen()));
 
 
 bool SdlVideoDeviceDriver::shutdown() {
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	SDL_QuitSubSystem(SDL_INIT_VIDEO);
 

File src/sdl2/wiesel/sdl2/video/sdl2_video_driver.cpp

 	if (platform) {
 		platform->removeReceiver(this);
 	}
-	
-	safe_release(render_context);
+
+	clear_ref(render_context);
 
 	return;
 }
 	}
 
 	// remove the old context, if any
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	// initialize the new render context
 	render_context = keep(new Sdl2GlRenderContext(getScreen()));
 
 
 bool Sdl2VideoDeviceDriver::shutdown() {
-	safe_release(render_context);
+	clear_ref(render_context);
 
 	SDL_QuitSubSystem(SDL_INIT_VIDEO);
 

File tests/base/shared_object.cpp

 	EXPECT_EQ(1, object->getReferenceCount());
 	
 	// now release the object
-	safe_release(object);
+	clear_ref(object);
 	
 	// the object's state should be 'destroyed'
 	EXPECT_EQ(State_Destroyed, state);
 	EXPECT_EQ(1, object2->getReferenceCount());
 	
 	// now release our extrnal reference
-	safe_release(object2);
+	clear_ref(object2);
 	
 	// the object's state should be 'destroyed'
 	EXPECT_EQ(State_Destroyed, state);

File tests/core/modules.cpp

 		ASSERT_EQ(17, testmod1->getTestValue());
 		
 		// release the object after usage
-		safe_release(testmod1);
+		clear_ref(testmod1);
 	}
 
 	// after we left the scope, the registry should be empty
 		ASSERT_EQ(0, TrackingModuleImpl::destruction_count);
 
 		// release the first module
-		safe_release(module1);
+		clear_ref(module1);
 
 		// the first one should be destructed, but the first one should be still alive.
 		ASSERT_EQ(2, TrackingModuleImpl::construction_count);
 	ASSERT_EQ(1, TrackingModuleImpl::destruction_count);
 
 	// now release the second module
-	safe_release(module2);
+	clear_ref(module2);
 
 	// ... and check, if it's really gone
 	ASSERT_EQ(2, TrackingModuleImpl::construction_count);
 		ASSERT_EQ(3, module2->getReferenceCount());
 
 		// release the first module
-		safe_release(module1);
+		clear_ref(module1);
 
 		// there should still be only one valid object, it should not be released
 		ASSERT_EQ(1, TrackingModuleImpl::construction_count);
 	ASSERT_EQ(1, module2->getReferenceCount());
 
 	// now release the second module
-	safe_release(module2);
+	clear_ref(module2);
 
 	// ... and check, if it's really gone
 	ASSERT_EQ(1, TrackingModuleImpl::construction_count);
 		EXPECT_EQ(17, testmod3->getTestValue());
 		
 		// release all modules after usage
-		safe_release(testmod1);
-		safe_release(testmod2);
-		safe_release(testmod3);
+		clear_ref(testmod1);
+		clear_ref(testmod2);
+		clear_ref(testmod3);
 	}
 
 	// after we left the scope, the registry should be empty
 		EXPECT_EQ(42, testmod3->getTestValue());
 		
 		// release all modules after usage
-		safe_release(testmod1);
-		safe_release(testmod2);
-		safe_release(testmod3);
+		clear_ref(testmod1);
+		clear_ref(testmod2);
+		clear_ref(testmod3);
 	}
 
 	// after we left the scope, the registry should be empty
 		EXPECT_EQ(23, testmod3->getTestValue());
 		
 		// release all modules after usage
-		safe_release(testmod1);
-		safe_release(testmod2);
-		safe_release(testmod3);
+		clear_ref(testmod1);
+		clear_ref(testmod2);
+		clear_ref(testmod3);
 	}
 
 	// after we left the scope, the registry should be empty