From 8913c30fc0b2d77c6739dbb717febee77b91794f Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 13 Aug 2019 18:19:32 +0800 Subject: [PATCH] fix compile warnings (#20028) --- cocos/2d/CCFontAtlas.cpp | 12 ------- cocos/2d/CCFontAtlas.h | 34 +++++++++---------- cocos/3d/CCMesh.cpp | 10 ------ cocos/3d/CCMeshVertexIndexData.cpp | 3 -- cocos/3d/CCVertexAttribBinding.cpp | 1 - .../ActionTimeline/CCActionTimeline.cpp | 2 +- cocos/navmesh/CCNavMeshDebugDraw.h | 1 - cocos/navmesh/CCNavMeshObstacle.cpp | 1 - cocos/platform/mac/CCCommon-mac.mm | 7 ++-- cocos/renderer/backend/Texture.cpp | 4 +-- cocos/ui/UIEditBox/UIEditBox.cpp | 26 +------------- cocos/ui/UIEditBox/UIEditBox.h | 32 ++++++++--------- cocos/ui/UIRichText.cpp | 1 - .../Particle3D/PU/CCPUBillboardChain.cpp | 1 - .../Particle3D/PU/CCPURibbonTrailRender.cpp | 1 - extensions/assets-manager/AssetsManagerEx.cpp | 22 +----------- extensions/assets-manager/AssetsManagerEx.h | 32 ++++++++--------- 17 files changed, 56 insertions(+), 134 deletions(-) diff --git a/cocos/2d/CCFontAtlas.cpp b/cocos/2d/CCFontAtlas.cpp index 958692d953..fbe43779cc 100644 --- a/cocos/2d/CCFontAtlas.cpp +++ b/cocos/2d/CCFontAtlas.cpp @@ -46,14 +46,6 @@ const char* FontAtlas::CMD_RESET_FONTATLAS = "__cc_RESET_FONTATLAS"; FontAtlas::FontAtlas(Font &theFont) : _font(&theFont) -, _fontFreeType(nullptr) -, _iconv(nullptr) -, _currentPageData(nullptr) -, _fontAscender(0) -, _rendererRecreatedListener(nullptr) -, _antialiasEnabled(true) -, _currLineHeight(0) -, _currentPageDataRGBA(nullptr) { _font->retain(); @@ -62,11 +54,7 @@ FontAtlas::FontAtlas(Font &theFont) { _lineHeight = _font->getFontMaxHeight(); _fontAscender = _fontFreeType->getFontAscender(); - _currentPage = 0; - _currentPageOrigX = 0; - _currentPageOrigY = 0; _letterEdgeExtend = 2; - _letterPadding = 0; if (_fontFreeType->isDistanceFieldEnabled()) { diff --git a/cocos/2d/CCFontAtlas.h b/cocos/2d/CCFontAtlas.h index aa492f0b6f..cb9930cbb3 100644 --- a/cocos/2d/CCFontAtlas.h +++ b/cocos/2d/CCFontAtlas.h @@ -135,26 +135,26 @@ protected: std::unordered_map _atlasTextures; std::unordered_map _letterDefinitions; - float _lineHeight; - Font* _font; - FontFreeType* _fontFreeType; - void* _iconv; + float _lineHeight = 0.f; + Font* _font = nullptr; + FontFreeType* _fontFreeType = nullptr; + void* _iconv = nullptr; // Dynamic GlyphCollection related stuff - int _currentPage; - unsigned char *_currentPageData; - unsigned char *_currentPageDataRGBA; - int _currentPageDataSize; - int _currentPageDataSizeRGBA; - float _currentPageOrigX; - float _currentPageOrigY; - int _letterPadding; - int _letterEdgeExtend; + int _currentPage = 0; + unsigned char *_currentPageData = nullptr; + unsigned char *_currentPageDataRGBA = nullptr; + int _currentPageDataSize = 0; + int _currentPageDataSizeRGBA = 0; + float _currentPageOrigX = 0; + float _currentPageOrigY = 0; + int _letterPadding = 0; + int _letterEdgeExtend = 0; - int _fontAscender; - EventListenerCustom* _rendererRecreatedListener; - bool _antialiasEnabled; - int _currLineHeight; + int _fontAscender = 0; + EventListenerCustom* _rendererRecreatedListener = nullptr; + bool _antialiasEnabled = true; + int _currLineHeight = 0; friend class Label; }; diff --git a/cocos/3d/CCMesh.cpp b/cocos/3d/CCMesh.cpp index 413bab89eb..77a0456633 100644 --- a/cocos/3d/CCMesh.cpp +++ b/cocos/3d/CCMesh.cpp @@ -529,16 +529,6 @@ void Mesh::bindMeshCommand() { if (_material && _meshIndexData) { - auto pass = _material->_currentTechnique->_passes.at(0); -// auto glprogramstate = pass->getGLProgramState(); - //auto texture = pass->getTexture(); - // auto textureid = texture ? texture->getName() : 0; - // XXX -// auto blend = pass->getStateBlock()->getBlendFunc(); - auto blend = BlendFunc::ALPHA_PREMULTIPLIED; - -//TODO -// _meshCommand.genMaterialID(textureid, glprogramstate, _meshIndexData->getVertexBuffer()->getVBO(), _meshIndexData->getIndexBuffer()->getVBO(), blend); _material->getStateBlock().setCullFace(true); _material->getStateBlock().setDepthTest(true); } diff --git a/cocos/3d/CCMeshVertexIndexData.cpp b/cocos/3d/CCMeshVertexIndexData.cpp index 2438424164..a185dac716 100644 --- a/cocos/3d/CCMeshVertexIndexData.cpp +++ b/cocos/3d/CCMeshVertexIndexData.cpp @@ -109,12 +109,9 @@ void MeshVertexData::setVertexData(const std::vector &vertexData) MeshVertexData* MeshVertexData::create(const MeshData& meshdata) { auto vertexdata = new (std::nothrow) MeshVertexData(); - int pervertexsize = meshdata.getPerVertexSize(); vertexdata->_vertexBuffer = backend::Device::getInstance()->newBuffer(meshdata.vertex.size() * sizeof(meshdata.vertex[0]), backend::BufferType::VERTEX, backend::BufferUsage::STATIC); //CC_SAFE_RETAIN(vertexdata->_vertexBuffer); - int offset = 0; - vertexdata->_sizePerVertex = meshdata.getPerVertexSize(); vertexdata->_attribs = meshdata.attribs; diff --git a/cocos/3d/CCVertexAttribBinding.cpp b/cocos/3d/CCVertexAttribBinding.cpp index 77df9a1ab4..abde589cfb 100644 --- a/cocos/3d/CCVertexAttribBinding.cpp +++ b/cocos/3d/CCVertexAttribBinding.cpp @@ -30,7 +30,6 @@ NS_CC_BEGIN -static uint32_t __maxVertexAttribs = 0; static std::vector __vertexAttribBindingCache; VertexAttribBinding::VertexAttribBinding() : diff --git a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp index a43e6fe8eb..be0e600abe 100644 --- a/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimeline.cpp @@ -250,7 +250,7 @@ void ActionTimeline::startWithTarget(Node *target) this->setTag(target->getTag()); foreachNodeDescendant(target, - [this, target](Node* child) + [this](Node* child) { ComExtensionData* data = dynamic_cast(child->getComponent("ComExtensionData")); diff --git a/cocos/navmesh/CCNavMeshDebugDraw.h b/cocos/navmesh/CCNavMeshDebugDraw.h index ae696972de..c6125c3b4f 100644 --- a/cocos/navmesh/CCNavMeshDebugDraw.h +++ b/cocos/navmesh/CCNavMeshDebugDraw.h @@ -100,7 +100,6 @@ private: backend::ProgramState * _programState = nullptr; bool _currentDepthMask = true; bool _dirtyBuffer = true; - backend::PrimitiveType _primitiveType = backend::PrimitiveType::POINT; backend::Buffer * _vertexBuffer = nullptr; //RenderState::StateBlock _stateBlock; diff --git a/cocos/navmesh/CCNavMeshObstacle.cpp b/cocos/navmesh/CCNavMeshObstacle.cpp index aef7e5c558..192347bef3 100644 --- a/cocos/navmesh/CCNavMeshObstacle.cpp +++ b/cocos/navmesh/CCNavMeshObstacle.cpp @@ -150,7 +150,6 @@ void NavMeshObstacle::syncToObstacle() if (_tileCache){ auto obstacle = _tileCache->getObstacleByRef(_obstacleID); if (obstacle){ - Vec3 worldPos = Vec3(obstacle->pos[0], obstacle->pos[1], obstacle->pos[2]); Mat4 mat = _owner->getNodeToWorldTransform(); if ((mat.m[12] != obstacle->pos[0] && mat.m[13] != obstacle->pos[1] && mat.m[14] != obstacle->pos[2]) || obstacle->radius != _radius diff --git a/cocos/platform/mac/CCCommon-mac.mm b/cocos/platform/mac/CCCommon-mac.mm index 1d022a37eb..948e5a2015 100644 --- a/cocos/platform/mac/CCCommon-mac.mm +++ b/cocos/platform/mac/CCCommon-mac.mm @@ -52,14 +52,11 @@ void MessageBox(const char * msg, const char * title) [alert addButtonWithTitle:@"OK"]; [alert setMessageText:tmpMsg]; [alert setInformativeText:tmpTitle]; - [alert setAlertStyle:NSWarningAlertStyle]; + [alert setAlertStyle:NSAlertStyleWarning]; auto glview = Director::getInstance()->getOpenGLView(); id window = glview->getCocoaWindow(); - [alert beginSheetModalForWindow:window - modalDelegate:[window delegate] - didEndSelector:nil - contextInfo:nil]; + [alert beginSheetModalForWindow:window completionHandler:nil]; } NS_CC_END diff --git a/cocos/renderer/backend/Texture.cpp b/cocos/renderer/backend/Texture.cpp index 9ff3a1d94f..68bd973b48 100644 --- a/cocos/renderer/backend/Texture.cpp +++ b/cocos/renderer/backend/Texture.cpp @@ -96,11 +96,11 @@ namespace TextureBackend::TextureBackend(const TextureDescriptor& descriptor) : _bitsPerElement(computeBitsPerElement(descriptor.textureFormat)) + , _width(descriptor.width) + , _height(descriptor.height) , _textureType(descriptor.textureType) , _textureFormat(descriptor.textureFormat) , _textureUsage(descriptor.textureUsage) - , _width(descriptor.width) - , _height(descriptor.height) { } diff --git a/cocos/ui/UIEditBox/UIEditBox.cpp b/cocos/ui/UIEditBox/UIEditBox.cpp index 23c814e366..d0c31c02b1 100755 --- a/cocos/ui/UIEditBox/UIEditBox.cpp +++ b/cocos/ui/UIEditBox/UIEditBox.cpp @@ -39,33 +39,9 @@ static const int DISABLED_RENDERER_Z = (-2); static const float CHECK_EDITBOX_POSITION_INTERVAL = 0.1f; EditBox::EditBox() -: _normalRenderer(nullptr) -, _pressedRenderer(nullptr) -, _disabledRenderer(nullptr) -, _normalFileName("") -, _pressedFileName("") -, _disabledFileName("") -, _normalTexType(TextureResType::LOCAL) -, _pressedTexType(TextureResType::LOCAL) -, _disabledTexType(TextureResType::LOCAL) -, _capInsetsNormal(Rect::ZERO) -, _capInsetsPressed(Rect::ZERO) -, _capInsetsDisabled(Rect::ZERO) -, _normalTextureSize(_contentSize) +: _normalTextureSize(_contentSize) , _pressedTextureSize(_contentSize) , _disabledTextureSize(_contentSize) -, _normalTextureLoaded(false) -, _pressedTextureLoaded(false) -, _disabledTextureLoaded(false) -, _normalTextureAdaptDirty(true) -, _pressedTextureAdaptDirty(true) -, _disabledTextureAdaptDirty(true) -, _editBoxImpl(nullptr) -, _delegate(nullptr) -, _adjustHeight(0.f) -#if CC_ENABLE_SCRIPT_BINDING -, _scriptEditBoxHandler(0) -#endif { } diff --git a/cocos/ui/UIEditBox/UIEditBox.h b/cocos/ui/UIEditBox/UIEditBox.h index 1229588211..1e8bb2fef5 100755 --- a/cocos/ui/UIEditBox/UIEditBox.h +++ b/cocos/ui/UIEditBox/UIEditBox.h @@ -675,9 +675,9 @@ namespace ui { protected: void updatePosition(float dt); - Scale9Sprite* _normalRenderer; - Scale9Sprite* _pressedRenderer; - Scale9Sprite* _disabledRenderer; + Scale9Sprite* _normalRenderer = nullptr; + Scale9Sprite* _pressedRenderer = nullptr; + Scale9Sprite* _disabledRenderer = nullptr; Rect _capInsetsNormal; Rect _capInsetsPressed; @@ -687,26 +687,26 @@ namespace ui { Size _pressedTextureSize; Size _disabledTextureSize; - bool _normalTextureLoaded; - bool _pressedTextureLoaded; - bool _disabledTextureLoaded; - bool _normalTextureAdaptDirty; - bool _pressedTextureAdaptDirty; - bool _disabledTextureAdaptDirty; + bool _normalTextureLoaded = false; + bool _pressedTextureLoaded = false; + bool _disabledTextureLoaded = false; + bool _normalTextureAdaptDirty = true; + bool _pressedTextureAdaptDirty = true; + bool _disabledTextureAdaptDirty = true; std::string _normalFileName; std::string _pressedFileName; std::string _disabledFileName; - TextureResType _normalTexType; - TextureResType _pressedTexType; - TextureResType _disabledTexType; + TextureResType _normalTexType = TextureResType::LOCAL; + TextureResType _pressedTexType = TextureResType::LOCAL; + TextureResType _disabledTexType = TextureResType::LOCAL; - EditBoxImpl* _editBoxImpl; - EditBoxDelegate* _delegate; + EditBoxImpl* _editBoxImpl = nullptr; + EditBoxDelegate* _delegate = nullptr; - float _adjustHeight; + float _adjustHeight = 0.f; #if CC_ENABLE_SCRIPT_BINDING - int _scriptEditBoxHandler; + int _scriptEditBoxHandler = 0; #endif }; } diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index bcf938fa26..72e604eb2e 100755 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -100,7 +100,6 @@ private: Node* _parent; // weak ref. std::string _url; RichText::OpenUrlHandler _handleOpenUrl; - EventDispatcher* _eventDispatcher; // weak ref. EventListenerTouchAllAtOnce* _touchListener; // strong ref. }; const std::string ListenerComponent::COMPONENT_NAME("cocos2d_ui_UIRichText_ListenerComponent"); diff --git a/extensions/Particle3D/PU/CCPUBillboardChain.cpp b/extensions/Particle3D/PU/CCPUBillboardChain.cpp index b60f1fea95..b4d5b9eb2d 100644 --- a/extensions/Particle3D/PU/CCPUBillboardChain.cpp +++ b/extensions/Particle3D/PU/CCPUBillboardChain.cpp @@ -767,7 +767,6 @@ void PUBillboardChain::onBeforeDraw() void PUBillboardChain::onAfterDraw() { auto *renderer = Director::getInstance()->getRenderer(); - auto &pipelineDescriptor = _meshCommand.getPipelineDescriptor(); renderer->setDepthTest(_rendererDepthTestEnabled); renderer->setDepthCompareFunction(_rendererDepthCmpFunc); renderer->setCullMode(_rendererCullMode); diff --git a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp index 9fbc39c06f..9e9f4576bd 100644 --- a/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp +++ b/extensions/Particle3D/PU/CCPURibbonTrailRender.cpp @@ -382,7 +382,6 @@ void PURibbonTrailRender::copyAttributesTo(PURibbonTrailRender *trailRender) void PURibbonTrailRender::updateParticles( const ParticlePool &pool ) { PURibbonTrailVisualData* visualData = nullptr; - Vec3 basePosition = static_cast(_particleSystem)->getDerivedPosition(); for (auto iter : pool.getActiveDataList()) { auto particle = static_cast(iter); diff --git a/extensions/assets-manager/AssetsManagerEx.cpp b/extensions/assets-manager/AssetsManagerEx.cpp index a790e48ccc..82eb8cdd2b 100644 --- a/extensions/assets-manager/AssetsManagerEx.cpp +++ b/extensions/assets-manager/AssetsManagerEx.cpp @@ -56,27 +56,7 @@ const std::string AssetsManagerEx::MANIFEST_ID = "@manifest"; // Implementation of AssetsManagerEx AssetsManagerEx::AssetsManagerEx(const std::string& manifestUrl, const std::string& storagePath) -: _updateState(State::UNCHECKED) -, _assets(nullptr) -, _storagePath("") -, _tempVersionPath("") -, _cacheManifestPath("") -, _tempManifestPath("") -, _manifestUrl(manifestUrl) -, _localManifest(nullptr) -, _tempManifest(nullptr) -, _remoteManifest(nullptr) -, _updateEntry(UpdateEntry::NONE) -, _percent(0) -, _percentByFile(0) -, _totalToDownload(0) -, _totalWaitToDownload(0) -, _nextSavePoint(0.0) -, _maxConcurrentTask(32) -, _currConcurrentTask(0) -, _versionCompareHandle(nullptr) -, _verifyCallback(nullptr) -, _inited(false) +: _manifestUrl(manifestUrl) { // Init variables _eventDispatcher = Director::getInstance()->getEventDispatcher(); diff --git a/extensions/assets-manager/AssetsManagerEx.h b/extensions/assets-manager/AssetsManagerEx.h index f9d2fb8b36..df7955f8d3 100644 --- a/extensions/assets-manager/AssetsManagerEx.h +++ b/extensions/assets-manager/AssetsManagerEx.h @@ -229,13 +229,13 @@ private: FileUtils *_fileUtils; //! State of update - State _updateState; + State _updateState = State::UNCHECKED; //! Downloader std::shared_ptr _downloader; //! The reference to the local assets - const std::unordered_map *_assets; + const std::unordered_map *_assets = nullptr; //! The path to store successfully downloaded version. std::string _storagePath; @@ -256,13 +256,13 @@ private: std::string _manifestUrl; //! Local manifest - Manifest *_localManifest; + Manifest *_localManifest = nullptr; //! Local temporary manifest for download resuming - Manifest *_tempManifest; + Manifest *_tempManifest = nullptr; //! Remote manifest - Manifest *_remoteManifest; + Manifest *_remoteManifest = nullptr; //! Whether user have requested to update enum class UpdateEntry : char @@ -272,7 +272,7 @@ private: DO_UPDATE }; - UpdateEntry _updateEntry; + UpdateEntry _updateEntry = UpdateEntry::NONE; //! All assets unit to download DownloadUnits _downloadUnits; @@ -284,16 +284,16 @@ private: std::vector _queue; //! Max concurrent task count for downloading - int _maxConcurrentTask; + int _maxConcurrentTask = 32; //! Current concurrent task count - int _currConcurrentTask; + int _currConcurrentTask = 0; //! Download percent - float _percent; + float _percent = 0.f; //! Download percent by file - float _percentByFile; + float _percentByFile = 0.f; //! Indicate whether the total size should be enabled int _totalEnabled; @@ -308,20 +308,20 @@ private: std::unordered_map _downloadedSize; //! Total number of assets to download - int _totalToDownload; + int _totalToDownload = 0; //! Total number of assets still waiting to be downloaded - int _totalWaitToDownload; + int _totalWaitToDownload = 0; //! Next target percent for saving the manifest file - float _nextSavePoint; + float _nextSavePoint = 0.f; //! Handle function to compare versions between different manifests - std::function _versionCompareHandle; + std::function _versionCompareHandle = nullptr; //! Callback function to verify the downloaded assets - std::function _verifyCallback; + std::function _verifyCallback = nullptr; //! Marker for whether the assets manager is inited - bool _inited; + bool _inited = false; }; NS_CC_EXT_END