]> git.lyx.org Git - lyx.git/commitdiff
Initialize client's name in main()
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 9 Sep 2024 13:29:39 +0000 (15:29 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 9 Sep 2024 13:33:02 +0000 (15:33 +0200)
Initializing clientName at declaration time is not a good idea.

Spotted by Coverity scan.

src/client/client.cpp

index 0a80107009020a7a8e1d6dba4392cc23d4583817..02ea67c00895fa2163a7614aa12a97098fe684d6 100644 (file)
@@ -460,8 +460,7 @@ int h(vector<docstring> const &)
 }
 
 
-docstring clientName =
-       from_ascii(to_string(::getppid()) + ">" + to_string(::getpid()));
+docstring clientName;
 
 int n(vector<docstring> const & arg)
 {
@@ -710,9 +709,12 @@ int LyXClientApp::run()
 
 int main(int argc, char * argv[])
 {
-       lyx::lyxerr.setStream(cerr);
+       using namespace lyx;
+       lyxerr.setStream(cerr);
+       cmdline::clientName =
+               from_ascii(to_string(::getppid()) + ">" + to_string(::getpid()));
 
-       lyx::LyXClientApp app(argc, argv);
+       LyXClientApp app(argc, argv);
        return app.exec();
 }