@@ -69,10 +69,6 @@ int main(int argc, char** argv) {
6969 // glibmm on core24 (the 2.68 ABI series) has no Glib::get_user_state_dir wrapper;
7070 // call the C g_get_user_state_dir() (glib 2.72+) directly for XDG_STATE_HOME.
7171 const std::string logDir = EnsureDir (g_get_user_state_dir (), " urnetwork" );
72- if (!host->Initialize (storageDir, logDir)) {
73- g_printerr (" failed to initialize SDK\n " );
74- return 1 ;
75- }
7672
7773 // Must match the .desktop StartupWMClass + common-id so the shell associates
7874 // the window with the app (and the hide-to-tray window keeps its identity).
@@ -88,6 +84,26 @@ int main(int argc, char** argv) {
8884 std::shared_ptr<urnw::Tray> tray;
8985
9086 app->signal_startup ().connect ([&] {
87+ // SDK INIT BELONGS HERE, NOT BEFORE app->run(). GApplication only decides
88+ // primary-vs-remote inside run(), so anything above it executes in EVERY
89+ // launch -- including a duplicate that is about to hand off to the running
90+ // instance and exit. signal_startup is emitted on the PRIMARY only.
91+ //
92+ // That distinction is not cosmetic. SdkHost::Initialize calls
93+ // urnet::setLogDir(), which runs the SDK's glog init: it sweeps the log
94+ // directory down to a keep-N budget and rewrites the
95+ // urnetwork-gui.{INFO,WARNING,ERROR} symlinks. A tester's bundle caught it
96+ // -- a second launch deleted three of the seven log files and left
97+ // urnetwork-gui.INFO, the file any "grab the current log" step follows,
98+ // naming its own 846-byte stub while the session that was actually running
99+ // had a 1.5 MB log the symlink no longer pointed at. Initialize also opens
100+ // the shared storage dir, which a process about to exit has no business
101+ // touching.
102+ if (!host->Initialize (storageDir, logDir)) {
103+ g_printerr (" failed to initialize SDK\n " );
104+ app->quit ();
105+ return ;
106+ }
91107 adw_init (); // libadwaita stylesheet + platform integration
92108 // the brand visual system is dark (mac app parity); the Ui.cpp stylesheet
93109 // layers the exact palette on top
0 commit comments