Skip to content

Commit f14543d

Browse files
committed
luxcoreui: Fix crash when changing scene (#663)
1 parent 54ee101 commit f14543d

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

samples/luxcoreui/luxcoreapp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ void LuxCoreApp::SetFilmResolution(const unsigned int width, const unsigned int
243243
StartRendering();
244244
}
245245

246-
void LuxCoreApp::LoadRenderConfig(const std::string &fileName) {
246+
void LuxCoreApp::LoadRenderConfig(const std::string &fileName, const std::string &filePath) {
247247
DeleteRendering();
248248

249249
// Set the current directory to place where the configuration file is
250-
boost::filesystem::current_path(boost::filesystem::path(fileName).parent_path());
250+
boost::filesystem::current_path(boost::filesystem::path(filePath));
251251

252252
// Clear the file name resolver list
253253
luxcore::ClearFileNameResolverPaths();

samples/luxcoreui/luxcoreapp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class LuxCoreApp {
106106
void DecScreenRefreshInterval();
107107
void CloseAllRenderConfigEditors();
108108

109-
void LoadRenderConfig(const std::string &configFileName);
109+
void LoadRenderConfig(const std::string &configFileName, const std::string &configFilePath);
110110
void StartRendering(luxcore::RenderState *startState = NULL, luxcore::Film *startFilm = NULL);
111111
void DeleteRendering();
112112

samples/luxcoreui/uimenu.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ static void KernelCacheFillProgressHandler(const size_t step, const size_t count
3939
enum fileBrowserType { open, save, save_directory };
4040

4141
bool fileBrowser(
42-
string &fileName,
42+
std::string &fileNamePath,
43+
std::string &filePath,
4344
const std::string &prompt,
4445
const std::vector<std::string> &filterList,
4546
fileBrowserType type
@@ -87,11 +88,13 @@ bool fileBrowser(
8788
{
8889
if (type != fileBrowserType::save_directory)
8990
{
90-
fileName = fd->GetFilePathName();
91+
fileNamePath = fd->GetFilePathName();
92+
filePath = fd->GetCurrentPath();
9193
}
9294
else
9395
{
94-
fileName = fd->GetCurrentPath();
96+
fileNamePath = fd->GetCurrentPath();
97+
filePath = fd->GetCurrentPath();
9598
}
9699
}
97100

@@ -553,6 +556,7 @@ void LuxCoreApp::MainMenuBar() {
553556
// File Dialogs
554557
if (showLoadFileDialog) {
555558
std::string fileToLoad;
559+
std::string fileToLoad_path;
556560
static const std::vector<std::string> filterLoad = {
557561
"LuxCore scenes (.cfg,.bcf,.lxs){.cfg,.bcf,.lxs}",
558562
"LuxCore scene - text (.cfg){.cfg}",
@@ -562,21 +566,24 @@ void LuxCoreApp::MainMenuBar() {
562566

563567
if (fileBrowser(
564568
fileToLoad,
569+
fileToLoad_path,
565570
"Select File to Load",
566571
filterLoad,
567572
fileBrowserType::open ))
568573
{
569574
showLoadFileDialog = false;
570-
LoadRenderConfig(fileToLoad);
575+
LoadRenderConfig(fileToLoad, fileToLoad_path);
571576
}
572577
}
573578

574579
if (showExportFileDialog) {
575580
std::string fileToExport;
581+
std::string fileToExport_path;
576582
static const std::vector<std::string> filterExport = {"All (.*){.*}"};
577583

578584
if (fileBrowser(
579585
fileToExport,
586+
fileToExport_path,
580587
"Select Directory to Export",
581588
filterExport,
582589
fileBrowserType::save_directory))
@@ -605,12 +612,14 @@ void LuxCoreApp::MainMenuBar() {
605612
if (showExportBinaryFileDialog)
606613
{
607614
std::string fileToExport;
615+
std::string fileToExport_path;
608616
static const std::vector<std::string> filterExport = {
609617
"LuxCore exported scene (.bcf){.bcf}"
610618
};
611619

612620
if (fileBrowser(
613621
fileToExport,
622+
fileToExport_path,
614623
"Select File to Export",
615624
filterExport,
616625
fileBrowserType::save))
@@ -624,13 +633,15 @@ void LuxCoreApp::MainMenuBar() {
624633
if (showExportGltfFileDialog)
625634
{
626635
std::string fileToExport;
636+
std::string fileToExport_path;
627637
static const std::vector<std::string> filterExport = {
628638
"glTF files (.glTF,.gltf){.glTF,.gltf}",
629639
"All files (.*){.*}",
630640
};
631641

632642
if (fileBrowser(
633643
fileToExport,
644+
fileToExport_path,
634645
"Select File to Export",
635646
filterExport,
636647
fileBrowserType::save))
@@ -644,13 +655,15 @@ void LuxCoreApp::MainMenuBar() {
644655
if (showSaveRenderingFileDialog)
645656
{
646657
std::string fileToExport;
658+
std::string fileToExport_path;
647659
static const std::vector<std::string> filterExport = {
648660
"LuxCore resume files (.rsm){.rsm}",
649661
"All files (.*){.*}",
650662
};
651663

652664
if (fileBrowser(
653665
fileToExport,
666+
fileToExport_path,
654667
"Select File to Save",
655668
filterExport,
656669
fileBrowserType::save))
@@ -672,19 +685,21 @@ void LuxCoreApp::MainMenuBar() {
672685
if (showResumeRenderingFileDialog)
673686
{
674687
std::string fileToLoad;
688+
std::string fileToLoad_path;
675689
static const std::vector<std::string> filterExport = {
676690
"LuxCore resume files (.rsm){.rsm}",
677691
"All files (.*){.*}",
678692
};
679693

680694
if (fileBrowser(
681695
fileToLoad,
696+
fileToLoad_path,
682697
"Select File to Load",
683698
filterExport,
684699
fileBrowserType::open))
685700
{
686701
showResumeRenderingFileDialog = false;
687-
LoadRenderConfig(fileToLoad);
702+
LoadRenderConfig(fileToLoad, fileToLoad_path);
688703
}
689704
} // Resume Rendering
690705

0 commit comments

Comments
 (0)