Skip to content

Commit

Permalink
Set FLTK to a stable tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Mar 13, 2023
1 parent 7b6b249 commit 05b5de9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cmake/Modules/BuildFLTK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
include( ExternalProject )

# Stable TAG
#set( FLTK_TAG 73a2ca5261ee7b0d0e33fc1e49611520d7b0e0cb )
set( FLTK_TAG master )
set( FLTK_TAG 73a2ca5261ee7b0d0e33fc1e49611520d7b0e0cb )
#set( FLTK_TAG master )


set( patch_cmd )
Expand Down
63 changes: 51 additions & 12 deletions mrv2/lib/mrvFl/mrvLanguages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,70 @@ LanguageTable kLanguages[18] = {
#ifdef _WIN32
namespace
{
//
// @bug: this routine fails if the executable is called from a directory
// wuth spaces in it. This routine quores the command with spaces
// but then _execv fails to run.
//
int win32_execv()
{
// Get the full command line string
LPWSTR lpCmdLine = GetCommandLineW();

// Enclose the command line string in quotes
size_t len = wcslen(lpCmdLine) + 3; // 2 for quotes, 1 for null terminator
LPWSTR cmd = (LPWSTR) malloc(len * sizeof(wchar_t));
if (cmd == NULL) {
wprintf(L"Failed to allocate memory for command line\n");
// Parse the command line string into an array of arguments
int argc;
LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);

if (argv == NULL) {
wprintf(L"Failed to parse command line\n");
return EXIT_FAILURE;
}
swprintf_s(cmd, len, L"\"%s\"", lpCmdLine);

// Call _wsystem with the quoted command string
int result = _wsystem(cmd);
// Construct a new array of arguments
LPWSTR* new_argv = (LPWSTR*) malloc((argc + 1) * sizeof(LPWSTR));
if (new_argv == NULL) {
wprintf(L"Failed to allocate memory for command line arguments\n");
return EXIT_FAILURE;
}
new_argv[0] = argv[0];
for (int i = 1; i < argc; i++) {
new_argv[i] = argv[i];
}
new_argv[argc] = NULL;

// Enclose argv[0] in double quotes if it contains spaces
LPWSTR cmd = argv[0];
if (wcschr(cmd, L' ') != NULL) {
size_t len = wcslen(cmd) + 3; // 2 for quotes, 1 for null terminator
LPWSTR quoted_cmd = (LPWSTR) malloc(len * sizeof(wchar_t));
if (quoted_cmd == NULL) {
wprintf(L"Failed to allocate memory for command line\n");
return EXIT_FAILURE;
}
swprintf_s(quoted_cmd, len, L"\"%s\"", cmd);
cmd = quoted_cmd;
}

// Call _wexecv with the command string and arguments in separate parameters
int result = _wexecv(cmd, new_argv);

if (result == -1) {
perror("_wsystem");
perror("_wexecv");
return EXIT_FAILURE;
}

// Free the memory used by the command string
free(cmd);
// Free the memory used by the new array of arguments
free(new_argv);

// Free the memory used by the quoted command line, if necessary
if (cmd != argv[0]) {
free(cmd);
}

// Free the array of arguments
LocalFree(argv);


exit(EXIT_SUCCESS);
}
}
Expand Down Expand Up @@ -105,7 +144,7 @@ void check_language(PreferencesUI* uiPrefs, int& language_index)
base.flush();

// deleete ViewerUI
mrv::Preferences::ui->uiMain->hide();
// mrv::Preferences::ui->uiMain->hide();

#ifdef _WIN32
win32_execv();
Expand Down

0 comments on commit 05b5de9

Please sign in to comment.