@@ -2763,11 +2763,11 @@ void IGFD::ThumbnailFeature::m_StartThumbnailFileDatasExtraction() {
27632763 if (!res) {
27642764 m_IsWorking = true ;
27652765 m_CountFiles = 0U ;
2766- m_ThumbnailGenerationThread = std::shared_ptr<std::thread>(new std::thread (&IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc, this ), [this ](std::thread* obj ) {
2766+ m_ThumbnailGenerationThread = std::shared_ptr<std::thread>(new std::thread (&IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc, this ), [this ](std::thread* obj_ptr ) {
27672767 m_IsWorking = false ;
2768- if (obj ) {
2768+ if (obj_ptr != nullptr ) {
27692769 m_ThumbnailFileDatasToGetCv.notify_all ();
2770- obj ->join ();
2770+ obj_ptr ->join ();
27712771 }
27722772 });
27732773 }
@@ -2778,14 +2778,12 @@ bool IGFD::ThumbnailFeature::m_StopThumbnailFileDatasExtraction() {
27782778 if (res) {
27792779 m_ThumbnailGenerationThread.reset ();
27802780 }
2781-
27822781 return res;
27832782}
27842783
27852784void IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc () {
27862785 m_CountFiles = 0U ;
27872786 m_IsWorking = true ;
2788-
27892787 // infinite loop while is thread working
27902788 while (m_IsWorking) {
27912789 std::unique_lock<std::mutex> thumbnailFileDatasToGetLock (m_ThumbnailFileDatasToGetMutex);
@@ -2796,15 +2794,12 @@ void IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc() {
27962794 file = (*m_ThumbnailFileDatasToGet.begin ());
27972795 m_ThumbnailFileDatasToGet.pop_front ();
27982796 thumbnailFileDatasToGetLock.unlock ();
2799-
28002797 // retrieve datas of the texture file if its an image file
28012798 if (file.use_count ()) {
2802- if (file->fileType .isFile ()) // -V522
2803- {
2799+ if (file->fileType .isFile ()) { // -V522
28042800 // || file->fileExtLevels == ".hdr" => format float so in few times
28052801 if (file->SearchForExts (" .png,.bmp,.tga,.jpg,.jpeg,.gif,.psd,.pic,.ppm,.pgm" , true )) {
2806- auto fpn = file->filePath + IGFD::Utils::GetPathSeparator () + file->fileNameExt ;
2807-
2802+ auto fpn = file->filePath + IGFD::Utils::GetPathSeparator () + file->fileNameExt ;
28082803 int w = 0 ;
28092804 int h = 0 ;
28102805 int chans = 0 ;
@@ -2816,34 +2811,26 @@ void IGFD::ThumbnailFeature::m_ThreadThumbnailFileDatasExtractionFunc() {
28162811 const float newX = DisplayMode_ThumbailsList_ImageHeight * ratioX;
28172812 float newY = w / ratioX;
28182813 if (newX < w) newY = DisplayMode_ThumbailsList_ImageHeight;
2819-
2820- const auto newWidth = (int )newX;
2821- const auto newHeight = (int )newY;
2822- const auto newBufSize = (size_t )(newWidth * newHeight * 4U ); // -V112 //-V1028
2823- auto resizedData = new uint8_t [newBufSize];
2824-
2825- const int resizeSucceeded = stbir_resize_uint8 (datas, w, h, 0 , resizedData, newWidth, newHeight, 0 ,
2826- 4 ); // -V112
2827-
2814+ const auto newWidth = (int )newX;
2815+ const auto newHeight = (int )newY;
2816+ const auto newBufSize = (size_t )(newWidth * newHeight * 4U ); // -V112 //-V1028
2817+ auto resizedData = new uint8_t [newBufSize];
2818+ const int resizeSucceeded = stbir_resize_uint8 (datas, w, h, 0 , resizedData, newWidth, newHeight, 0 , 4 ); // -V112
28282819 if (resizeSucceeded) {
2829- auto th = &file->thumbnailInfo ;
2830-
2820+ auto th = &file->thumbnailInfo ;
28312821 th->textureFileDatas = resizedData;
28322822 th->textureWidth = newWidth;
28332823 th->textureHeight = newHeight;
28342824 th->textureChannels = 4 ; // -V112
2835-
28362825 // we set that at least, because will launch the gpu creation of the texture in the
28372826 // main thread
28382827 th->isReadyToUpload = true ;
2839-
28402828 // need gpu loading
28412829 m_AddThumbnailToCreate (file);
28422830 }
28432831 } else {
28442832 printf (" image loading fail : w:%i h:%i c:%i\n " , w, h, 4 ); // -V112
28452833 }
2846-
28472834 stbi_image_free (datas);
28482835 }
28492836 }
@@ -2869,9 +2856,8 @@ void IGFD::ThumbnailFeature::m_VariadicProgressBar(float fraction, const ImVec2&
28692856void IGFD::ThumbnailFeature::m_DrawThumbnailGenerationProgress () {
28702857 if (m_ThumbnailGenerationThread.use_count () && m_ThumbnailGenerationThread->joinable ()) {
28712858 if (!m_ThumbnailFileDatasToGet.empty ()) {
2872- const auto p = (float )((double )m_CountFiles / (double )m_ThumbnailFileDatasToGet.size ()); // read => no thread concurency issues
2873- m_VariadicProgressBar (p, ImVec2 (50 , 0 ), " %u/%u" , m_CountFiles,
2874- (uint32_t )m_ThumbnailFileDatasToGet.size ()); // read => no thread concurency issues
2859+ const auto p = (float )((double )m_CountFiles / (double )m_ThumbnailFileDatasToGet.size ()); // read => no thread concurency issues
2860+ m_VariadicProgressBar (p, ImVec2 (50 , 0 ), " %u/%u" , m_CountFiles, (uint32_t )m_ThumbnailFileDatasToGet.size ()); // read => no thread concurency issues
28752861 ImGui::SameLine ();
28762862 }
28772863 }
0 commit comments