Skip to content

Commit b2f4da2

Browse files
authored
Fix handling of multiple files with spaces in names. (#1030)
Space escaping was overwriting the original file name which did not need escaped spaces causing failure on subsequent opens of the file which happen when cycling through a list of files.
1 parent b167e96 commit b2f4da2

5 files changed

Lines changed: 7 additions & 9 deletions

File tree

tests/loadtests/glloadtests/GLLoadTests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GLLoadTests : public GLAppSDL {
5454
eBack
5555
};
5656
void invokeSample(Direction dir);
57-
LoadTestSample* showFile(std::string& filename);
57+
LoadTestSample* showFile(const std::string& filename);
5858
LoadTestSample* pCurSample;
5959

6060
bool quit = false;

tests/loadtests/glloadtests/gles1/ES1LoadTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "TexturedCube.h"
2323

2424
LoadTestSample*
25-
GLLoadTests::showFile(std::string& filename)
25+
GLLoadTests::showFile(const std::string& filename)
2626
{
2727
KTX_error_code ktxresult;
2828
ktxTexture* kTexture;

tests/loadtests/glloadtests/shader-based/GL3LoadTests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#endif
3333

3434
LoadTestSample*
35-
GLLoadTests::showFile(std::string& filename)
35+
GLLoadTests::showFile(const std::string& filename)
3636
{
3737
KTX_error_code ktxresult;
3838
ktxTexture* kTexture;
@@ -76,8 +76,7 @@ GLLoadTests::showFile(std::string& filename)
7676
ktxTexture_Destroy(kTexture);
7777

7878
// Escape any spaces in filename.
79-
filename = std::regex_replace( filename, std::regex(" "), "\\ " );
80-
std::string args = "--external " + filename;
79+
std::string args = "--external " + std::regex_replace( filename, std::regex(" "), "\\ " );
8180
pViewer = createViewer(w_width, w_height, args.c_str(), sBasePath);
8281
return pViewer;
8382
}

tests/loadtests/vkloadtests/VulkanLoadTests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ VulkanLoadTests::onFPSUpdate()
323323
}
324324

325325
VulkanLoadTestSample*
326-
VulkanLoadTests::showFile(std::string& filename)
326+
VulkanLoadTests::showFile(const std::string& filename)
327327
{
328328
KTX_error_code ktxresult;
329329
ktxTexture* kTexture;
@@ -359,8 +359,7 @@ VulkanLoadTests::showFile(std::string& filename)
359359
ktxTexture_Destroy(kTexture);
360360

361361
// Escape any spaces in filename.
362-
filename = std::regex_replace( filename, std::regex(" "), "\\ " );
363-
std::string args = "--external " + filename;
362+
std::string args = "--external " + std::regex_replace( filename, std::regex(" "), "\\ " );
364363
pViewer = createViewer(vkctx, w_width, w_height, args.c_str(), sBasePath);
365364
return pViewer;
366365
}

tests/loadtests/vkloadtests/VulkanLoadTests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class VulkanLoadTests : public VulkanAppSDL {
4242
eBack
4343
};
4444
void invokeSample(Direction dir);
45-
VulkanLoadTestSample* showFile(std::string& filename);
45+
VulkanLoadTestSample* showFile(const std::string& filename);
4646
VulkanLoadTestSample* pCurSample;
4747

4848
bool quit = false;

0 commit comments

Comments
 (0)