FabDev 8 Posted November 10, 2022 Hello, I try to da a Style tester on Android, IOS, Window and MacOs. It's a form with most of visual components and a style selector. For that I use : FMX.Styles.TStyleManager.SetStyleFromFile(SytleFileName); It's work but I have random access violation Exception 'first chance' at $00F0CD3A. Exception class $C0000005 with a message 'access violation at 0x00f0cd3a: read of address 0x0907728b'. Processus StyleTest.exe (10884) in FMX.Objects in all platform : function TText.GetColor: TAlphaColor; begin Result := FTextSettings.FontColor; end; I have tried something like : try BeginUpdate; FMX.Styles.TStyleManager.SetStyleFromFile(SytleFileName); finally EndUpdate; end; Or using Thread : TThread.Synchronize( nil, procedure begin try try BeginUpdate; ok:=FMX.Styles.TStyleManager.SetStyleFromFile(StyleFilename); finally endupdate; end; except ok:=false; end; end ); But it's doesn't fix the problem. Or does it a bad idea to change style at runtime ? Share this post Link to post
Lajos Juhász 293 Posted November 10, 2022 6 minutes ago, FabDev said: Or does it a bad idea to change style at runtime ? It's not. There were Embarcadero webinars on this topic. Share this post Link to post
Rollo62 536 Posted November 10, 2022 Maybe that info helps too https://docwiki.embarcadero.com/RADStudio/Sydney/en/Working_with_Native_and_Custom_FireMonkey_Styles https://docwiki.embarcadero.com/RADStudio/Sydney/en/Applying_FireMonkey_Styles Does a call to ApplyStyleLookup() help ? https://docwiki.embarcadero.com/Libraries/Sydney/en/FMX.Forms.TCustomForm.ApplyStyleLookup Share this post Link to post
FabDev 8 Posted November 10, 2022 (edited) I confirm that SetStyleFromFile can (must ?) be used in Application.Initialize) or in the initialization section of one of the form unit : https://docwiki.embarcadero.com/Libraries/Alexandria/en/FMX.Styles.TStyleManager.SetStyleFromFile But I have found another solution which doesn't seems to give AV on IOS/Win32/Android : StyleBook:=nil; StyleBook1.Clear; StyleBook1.LoadFromFile(StyleFileName); StyleBook:= StyleBook1; Or the unique way, I have tested, it's to only use it in Application.Initialize (or Initalization section) ? Edited November 11, 2022 by FabDev Share this post Link to post