From 4f5432f4274ca22ae5df7d23988a3357e7ddc5fd Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 17 Nov 2006 16:58:32 +0000 Subject: [PATCH] * docstring.C: add a FIXME in utf8_to_ucs4() WRT static IconvProcessor and Mac * lyx_main.C: - LyX::prepareExit(): avoid utf8_to_ucs4() conversion at this late stage because this can cause problem on Mac. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15955 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/lyx_main.C | 8 +++++--- src/support/docstring.C | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lyx_main.C b/src/lyx_main.C index 104376cd77..389647b562 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -387,9 +387,11 @@ void LyX::prepareExit() lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl; if (!destroyDir(package().temp_dir())) { - docstring const msg = - bformat(_("Unable to remove the temporary directory %1$s"), - from_utf8(package().temp_dir())); + // FIXME UNICODE: package().temp_dir() could in theory contain utf8 characters. + // We cannot use from_utf8() here because this involves the use of static data + // that may have been destroyed already on Mac systems. + docstring const msg = _("Unable to remove the temporary directory") + " " + + package().temp_dir().c_str(); Alert::warning(_("Unable to remove temporary directory"), msg); } } diff --git a/src/support/docstring.C b/src/support/docstring.C index b3039edb5a..b3e8a76b1e 100644 --- a/src/support/docstring.C +++ b/src/support/docstring.C @@ -57,6 +57,12 @@ std::string const to_ascii(docstring const & ucs4) void utf8_to_ucs4(std::string const & utf8, docstring & ucs4) { + // FIXME (Abdel 17/11/06): static data are evil! + // This function cannot be used in the final exit process on Mac because + // static data are already destroyed at this stage. + // One solution would be to instantiate the utf8 to ucs4 IconvProcessor as a + // singleton inside the LyX main class to ensure that it does not get + // destroyed too early. static IconvProcessor iconv(ucs4_codeset, "UTF-8"); size_t n = utf8.size(); -- 2.39.2