mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Handle properly exception that can be thrown by to_local8bit
Remove the use of this function in GuiAlert. This was spotted by coverity
This commit is contained in:
parent
91ca310d1d
commit
522f3517e1
@ -211,9 +211,8 @@ void doError(docstring const & title0, docstring const & message, bool backtrace
|
||||
<< toPlainText(message) << endl;
|
||||
|
||||
QString details;
|
||||
if (backtrace) {
|
||||
details = QString::fromLocal8Bit(to_local8bit(printCallStack()).c_str());
|
||||
}
|
||||
if (backtrace)
|
||||
details = toqstr(printCallStack());
|
||||
|
||||
if (!use_gui)
|
||||
return;
|
||||
|
@ -57,7 +57,13 @@ bool setEnv(string const & name, string const & value)
|
||||
// CHECK Look at and fix this.
|
||||
// f.ex. what about error checking?
|
||||
|
||||
string const encoded = to_local8bit(from_utf8(value));
|
||||
string encoded;
|
||||
try {
|
||||
encoded = to_local8bit(from_utf8(value));
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined (HAVE_SETENV)
|
||||
return ::setenv(name.c_str(), encoded.c_str(), 1) == 0;
|
||||
#elif defined (HAVE_PUTENV)
|
||||
|
@ -456,8 +456,16 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode,
|
||||
cygwin_internal(CW_SYNC_WINENV);
|
||||
}
|
||||
|
||||
string win_path;
|
||||
try {
|
||||
win_path = to_local8bit(from_utf8(convert_path(filename, PathStyle(windows))));
|
||||
} catch (...) {
|
||||
LYXERR0("Cannot encode file name `" << filename << "' to local 8 bit encoding");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
||||
string const win_path = to_local8bit(from_utf8(convert_path(filename, PathStyle(windows))));
|
||||
char const * action = (mode == VIEW) ? "open" : "edit";
|
||||
bool success = reinterpret_cast<long>(ShellExecute(NULL, action,
|
||||
win_path.c_str(), NULL, NULL, 1)) > 32;
|
||||
|
@ -567,10 +567,18 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode,
|
||||
setEnv("TEXFONTS", newtexfonts);
|
||||
}
|
||||
|
||||
string fname8;
|
||||
try {
|
||||
fname8 = to_local8bit(from_utf8(filename));
|
||||
} catch (...) {
|
||||
LYXERR0("Cannot encode file name `" << filename << "' to local 8 bit encoding");
|
||||
return false;
|
||||
}
|
||||
|
||||
// reference: http://msdn.microsoft.com/en-us/library/bb762153.aspx
|
||||
char const * action = (mode == VIEW) ? "open" : "edit";
|
||||
bool success = reinterpret_cast<intptr_t>(ShellExecute(NULL, action,
|
||||
to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32;
|
||||
fname8.c_str(), NULL, NULL, 1)) > 32;
|
||||
|
||||
if (!path.empty() && !lyxrc.texinputs_prefix.empty()) {
|
||||
setEnv("TEXINPUTS", oldtexinputs);
|
||||
|
Loading…
Reference in New Issue
Block a user