Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Missing value_or() when printing std::optional #294

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

srifqi
Copy link
Member

@srifqi srifqi commented Feb 23, 2024

I found a compilation error when compiling IrrlichtMT in Debug mode. Because joint->Name has std::optional type, value_or() needs to be called first before c_str() (from std::string).

diff --git a/source/Irrlicht/CB3DMeshFileLoader.cpp b/source/Irrlicht/CB3DMeshFileLoader.cpp
index 85f76a4..59f35fd 100644
--- a/source/Irrlicht/CB3DMeshFileLoader.cpp
+++ b/source/Irrlicht/CB3DMeshFileLoader.cpp
@@ -158,7 +158,7 @@ bool CB3DMeshFileLoader::readChunkNODE(CSkinnedMesh::SJoint *inJoint)
 	for ( u32 i=1; i < B3dStack.size(); ++i )
 		logStr += "-";
 	logStr += "read ChunkNODE";
-	os::Printer::log(logStr.c_str(), joint->Name.c_str(), ELL_DEBUG);
+	os::Printer::log(logStr.c_str(), joint->Name.value_or("").c_str(), ELL_DEBUG);
 #endif
 
 	f32 position[3], scale[3], rotation[4];

@srifqi srifqi added the bug Something isn't working label Feb 23, 2024
@sfan5 sfan5 merged commit 2db8c87 into minetest:master Feb 23, 2024
19 checks passed
@srifqi srifqi deleted the fix_optional_value_or branch February 23, 2024 14:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants