[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] (no subject)
From: |
Greg Chicares |
Subject: |
[lmi-commits] (no subject) |
Date: |
Fri, 3 Jun 2016 21:31:03 +0000 (UTC) |
branch: master
commit 5d4c24a0ff1f1c88696190108975e5d2d3b80e3b
Author: Gregory W. Chicares <address@hidden>
Date: Fri Jun 3 21:29:45 2016 +0000
Preload designated DLLs after parsing the command line, redux [439]
'configurable_settings.cpp': A defect has actually been removed. It is
not reasonably practicable to detect whether the command line has yet
been parsed, but it's general knowledge that it should be parsed early.
'install_msw.sh': At last, thanks to Vadim's immediately-preceding
commit, we can install 'configurable_settings.xml' where it always
should have been installed.
'main_wx_test.cpp': Preload DLLs only after parsing command line,
parallelling the change already made elsewhere.
'skeleton.cpp': Preload DLLs as the very next step after parsing the
command line, making it unnecessary to consider whether authentication
relies on FPU state.
---
configurable_settings.cpp | 7 +++----
install_msw.sh | 2 +-
main_wx_test.cpp | 9 +++++----
skeleton.cpp | 13 +++++++------
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/configurable_settings.cpp b/configurable_settings.cpp
index c669ad6..42ccb9b 100644
--- a/configurable_settings.cpp
+++ b/configurable_settings.cpp
@@ -61,7 +61,9 @@ std::string const& configuration_filename()
///
/// Look for the configuration file first where FHS would have it.
/// To support non-FHS platforms, if it's not readable there, then
-/// look in the data directory.
+/// look in the data directory. Care should be taken to parse the
+/// command line early in main(), particularly because it may use
+/// '--data_path' to specify the data directory.
///
/// Throws if the file is not readable.
///
@@ -92,9 +94,6 @@ fs::path const& configuration_filepath()
std::string filename = "/etc/opt/lmi/" + configuration_filename();
if(0 != access(filename.c_str(), R_OK))
{
- // TODO ?? At this point, AddDataDir() might refer to the directory
- // where the wx binary resides if ProcessCommandLine() hadn't been
- // called yet. We should arguably detect this case and give an error.
filename = AddDataDir(configuration_filename());
if(0 != access(filename.c_str(), R_OK))
{
diff --git a/install_msw.sh b/install_msw.sh
index c8c9304..4aea721 100755
--- a/install_msw.sh
+++ b/install_msw.sh
@@ -166,7 +166,7 @@ echo -n "8fa614e38dde6f7ab0f9fade87dfa2e3"
>/opt/lmi/data/passkey
# Tailored to msw; for POSIX, s|C:|| and s|CMD /c|/bin/sh| (e.g.).
-cat >/opt/lmi/bin/configurable_settings.xml <<EOF
+cat >/opt/lmi/data/configurable_settings.xml <<EOF
<?xml version="1.0"?>
<configurable_settings version="2">
<calculation_summary_columns/>
diff --git a/main_wx_test.cpp b/main_wx_test.cpp
index 33023c6..f85c3dc 100644
--- a/main_wx_test.cpp
+++ b/main_wx_test.cpp
@@ -30,7 +30,7 @@
#include "force_linking.hpp"
#include "handle_exceptions.hpp" // stealth_exception
#include "main_common.hpp" // initialize_application()
-#include "msw_workarounds.hpp"
+#include "msw_workarounds.hpp" // PreloadDesignatedDlls()
#include "obstruct_slicing.hpp"
#include "path_utility.hpp" // initialize_filesystem()
#include "skeleton.hpp"
@@ -907,9 +907,6 @@ int main(int argc, char* argv[])
{
initialize_application();
initialize_filesystem();
-#ifdef LMI_MSW
- MswDllPreloader::instance().PreloadDesignatedDlls();
-#endif
// We need to handle test-specific options and remove them from argv before
// letting wxEntry() instantiate Skeleton application object that would
@@ -919,6 +916,10 @@ int main(int argc, char* argv[])
return 0;
}
+#ifdef LMI_MSW
+ MswDllPreloader::instance().PreloadDesignatedDlls();
+#endif
+
return wxEntry(argc, argv);
}
diff --git a/skeleton.cpp b/skeleton.cpp
index 96b46e6..2c0c9fe 100644
--- a/skeleton.cpp
+++ b/skeleton.cpp
@@ -66,7 +66,7 @@
#include "mec_document.hpp"
#include "mec_view.hpp"
#include "miscellany.hpp"
-#include "msw_workarounds.hpp"
+#include "msw_workarounds.hpp" // PreloadDesignatedDlls()
#include "mvc_controller.hpp"
#include "policy_document.hpp"
#include "policy_view.hpp"
@@ -691,13 +691,14 @@ bool Skeleton::OnInit()
return false;
}
- authenticate_system();
-
- // It is important for this line to be after ProcessCommandLine() call
- // as it uses configurable_settings which is loaded from the file whose
- // location can be specified using a command line option.
+ // Preload DLLs after calling ProcessCommandLine(). Reason:
+ // command-line option '--data_path' may specify the directory
+ // from which 'configurable_settings.xml' is read, and that
+ // XML file gives the list of DLLs to preload.
MswDllPreloader::instance().PreloadDesignatedDlls();
+ authenticate_system();
+
wxInitAllImageHandlers();
// For GTK+, native theme takes precedence over local icons.