Skip to content

Commit 3163da9

Browse files
committed
demo banner injection fixes
1 parent 4872a0b commit 3163da9

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

src/switchcraft/gui_modern/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ def setup_page(self):
635635
self.dev_banner_container = ft.Container()
636636

637637
# Demo Banner
638-
if IS_DEMO:
638+
if IS_DEMO or SwitchCraftConfig.is_demo_mode():
639639
self.banner_container = ft.Container(
640640
content=ft.Row(
641641
[

src/switchcraft/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ def legacy_show_snack(snack):
460460
except Exception:
461461
pass
462462

463+
# --- Initialize Global App State ---
464+
import switchcraft
465+
switchcraft.IS_DEMO = SwitchCraftConfig.is_demo_mode()
466+
463467
page.theme_mode = ft.ThemeMode.SYSTEM
464468
page.padding = 0
465469
page.spacing = 0

src/switchcraft/utils/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,12 @@ def is_debug_mode(cls) -> bool:
672672
if os.environ.get("SWITCHCRAFT_DEBUG") == "1": return True
673673
return cls.get_value("DebugMode", 0) == 1
674674

675+
@classmethod
676+
def is_demo_mode(cls) -> bool:
677+
"""Check if demo mode is enabled via config or CLI."""
678+
if '--demo' in sys.argv: return True
679+
return cls.get_value("DemoMode", 0) == 1 or cls.get_value("demo_mode", False) == True
680+
675681
@classmethod
676682
def get_update_channel(cls) -> str:
677683
return cls.get_value("UpdateChannel", "stable")

switchcraft.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ var
225225
ErrorCode: Integer;
226226
begin
227227
Result := True;
228-
// Silently kill the process if it's running
229-
Exec('taskkill.exe', '/F /IM {#MyAppExeName} /T', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
228+
// Silently kill the process only if it's running from the installation directory (avoids killing portable versions)
229+
Exec('powershell.exe', '-ExecutionPolicy Bypass -WindowStyle Hidden -Command "Get-Process -Name ' + Copy('{#MyAppExeName}', 1, Pos('.exe', LowerCase('{#MyAppExeName}')) - 1) + ' -ErrorAction SilentlyContinue | Where-Object { $_.Path -like ''' + ExpandConstant('{app}') + '\*'' } | Stop-Process -Force"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
230230
231231
// Check for /FULLCLEANUP parameter
232232
FullCleanupParam := False;

switchcraft_legacy.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ var
207207
ErrorCode: Integer;
208208
begin
209209
Result := True;
210-
// Silently kill the process if it's running
211-
Exec('taskkill.exe', '/F /IM {#MyAppExeName} /T', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
210+
// Silently kill the process only if it's running from the installation directory (avoids killing portable versions)
211+
Exec('powershell.exe', '-ExecutionPolicy Bypass -WindowStyle Hidden -Command "Get-Process -Name ' + Copy('{#MyAppExeName}', 1, Pos('.exe', LowerCase('{#MyAppExeName}')) - 1) + ' -ErrorAction SilentlyContinue | Where-Object { $_.Path -like ''' + ExpandConstant('{app}') + '\*'' } | Stop-Process -Force"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
212212
213213
// Check for /FULLCLEANUP parameter
214214
FullCleanupParam := False;

0 commit comments

Comments
 (0)