Tag: firemonkey

FMX TMetropolisUIListBoxItem Scrolling error

I am building an application using fmx where a TListbox adds TMetropolisUIListBoxItem using ini file. The problem is, while user scrolls the listbox, "Invalid Pointer Operation" error shows up. Here's the code of adding TMetropolisUIListBoxItems. MemINI := TMemINIfile.Create(System.IOUtils.TPath.GetFileNameWithoutExtension(paramstr(0)) + '.ini'); Alist := TStringlist.Create; MemINI.ReadSections(Alist); Setlength(Stu, Alist.Count); for var I := 0 to Alist.Count - 1 do begin Stu[I] := TMetropolisUIListBoxItem.Create(ListBox1); Stu[I].Description := MemINI.ReadString(Alist.Strings[I], 'Notes', ''); Stu[I].SubTitle := MemINI.ReadString(Alist.Strings[I], 'ID', ''); Stu[I].Title := Alist.Strings[I]; if fileexists(MemINI.ReadString(Alist.Strings[I], 'Icon', Stu[I].Title)) then Stu[I].Icon.LoadFromFile(includetrailingbackslash(GetCurrentdir) + MemINI.ReadString(Alist.Strings[I], 'Icon', Stu[I].Title)); Stu[I].Parent := ListBox1; end; Alist.Free; Memini.Free; I don't face an error if I have a few items and don't have to scroll. It's just when there are a lot of items in the list and the items need to be scrolled. User scrolls up/down and "Invalid Pointer Operation" shows up. The delphi debugger refers to TObject.free while throwing the error but I don't see a reference of freeing something here.
Read More

Alternative for Listview on a TTabsheet / TTabControl and SetActiveTabWithTransition on android?

I use Rad Studio 10.4 Enterprise with all 3 updates. The transition animation on SetActiveTabWithTransition only works on windows for me. On android it just shows me the other ttabsheet. I don't need fancy stuff. But i still want to give the user some visual feedback when he taps an entry in a Listview. After some reading i also realized that firemonkey has performance issues on android when it comes to transitions with some controls on the screen. My choice right now is 3 Listviews each one having width of the viewport (?) left aligned on a panel that is 3 times the width of the viewport. On a click on a listview, instead of using SetActiveTabWithTransition to switch to the next ttabsheet, i use tanimator.animatefloat on the panel to set position.x of the panel to the position of the next listview. In my opionion that doesn't feel "clean". At least it is smooth as butter concerning the transition. Even on a very old android device. What would be a better choice? Thank you very much
Read More

A bunch of Spring4D dependency injection container related questions

Since G+ is down, a lot of interesting questions have vanished. Luckily I saved some by [WayBack] Jacek Laskowski – Google+ related to Spring4D and dependency injection: [WayBack] Spring4D IoC and specific singleton… – Jacek Laskowski – Google+ First my Google Groups archival reminder: Rename from https://groups.google.com/forum/?hl=en#!topic/spring4d/zZZXOmMzF4I To https://groups.google.com/d/topic/spring4d/zZZXOmMzF4I Save that URL with Archive.is Q: [WayBack] Spring4D – How to get the same instance of Logger for a class group?… – Jacek Laskowski – Google+ Everything works on interfaces, but I skip interfaces for simplicity. I have a base class:  TBaseClass = class   fLogger : TLogger;  end; Two usable classes are inherited from it:  TClassA = class(TBaseClass)   fWorkClass1 : TWorkClassA;     fWorkClass2 : TWorkClassB;  end; TClassB = class(TBaseClass)   fWorkClass3 : TWorkClassC;   fWorkClass4 : TWorkClassD;  end; …which have working classes:  TWorkClassA = class   fLogger : TLogger;  end; TWorkClassB = class   fLogger : Tlogger;  end; TWorkClassC = class   fLogger : TLogger;  end; TWorkClassD = class   fLogger : Tlogger;  end; These objects I use directly in the code: var  ObjectA : TClassA;  ObjectB : TClassB; ObjectA and ObjectB create their own separate workgroups, and I would like all classes in the group to use the same fLogger instance. I would like to create two instances of TLogger: first for objects: ObjectA, fWorkClass1, fWorkClass2 second for object: ObjectB, fWorkClass3, fWorkClass4 How to register and get from Spring4D? A: [Archive.is] [IoC and DI] Specific instances for object groups – Google Groups Honza Rameš Hi Jacek, I’d recommend using named injections. (Stefan has some surprises that might allow you to achieve similar functionality differently, stay tuned for 1.3 ;-) ). Honza Stefan Glienke You can write your own resolver that handles TLogger and injects the same instance based on some criteria (like a Logger(‘groupname’) attribute on your injection target or something like that) Q: [WayBack] How to debug resolver issues in Spring4D?… – Jacek Laskowski – Google+ How to debug resolver issues in Spring4D? When in constructor occur unregistered type parameter (or registered, but uncompletly – without register his constructor parameters types), Spring creates the object with a bad constructor (without parameters, come from base class), but does not warn about it! And an unfinished object is created, with nil in the key fields. How to avoid this, how to detect it? A: Baoquan Zuo It also happened to me yesterday, in my case, it was caused by a RTTI directive which prevent Spring container locating constructor in component type as compiler didn’t emit them. I wanted to post in the group about adding trace log and warnings about possible errors. Jacek Laskowski In my case class has interface, but I register only class without explicitly register interface (RegisterType<TMyClass>) and container found and register only interface, and when I try resolve class then class not found. After correct code to RegisterType<TMyClass, TMyClass> problem disappear. But trace log would by very useful! Stefan Glienke+1 There is the unit [WayBack]Spring.Container.ActivatorExtension which has a container extension that prevents the container to fall back on the parameterless ctor. Jacek Laskowski +Stefan Glienke You mean [WayBack] TActivatorInspector? How to use it? Stefan Glienke Add the extension to the container. Q: [WayBack] Spring resolver problem… I try resolve factory method (previously registered in container) and I get compile error… – Jacek Laskowski – Google+ Spring resolver problem… I try resolve factory method (previously registered in container) and I get compile error: {$M+} TCompaniesManagerFactory = reference to function(const aAuthKey : RAuthKey) : ICompaniesManager; {$M-} var lCompaniesManagerFactory : TCompaniesManagerFactory; begin lCompaniesManagerFactory := Container.Resolve<TCompaniesManagerFactory>; // <- line with error Error: [dcc32 Error] E2010 Incompatible types: 'TCompaniesManagerFactory' and 'Procedure of object' ps. I know about composition root and others IoC rules… please tell me why I get compile error, types are compatible A: Stefan Glienke+4 Put parentheses on your call. When assigning a function call result to an anonymous method variable it does not consider calling the method to get an assignment compatible result. Most simple case: uses   System.SysUtils; function GiveProc: TProc; begin end; var   p: TProc; begin   p := GiveProc; // <- E2010 - write GiveProc() and it works end. Q: [WayBack] Spring4D, register factory… default parameters… – Jacek Laskowski – Google+ Sprin4D, register factory I have a class that implements the interface: TMyClass = class(TInterfacedObject, IMyInterface) public constructor Create(ParamA : string; ParamB : Integer; ParamC : Boolean); end; and the factory: TMyInterfaceFactoryA = reference to function(ParamA : string; ParamB : Integer; ParamC : Boolean) : IMyInterface; which I register in the spring: Container.RegisterType<IMyInterface, TMyClass>; Container.RegisterFactory<TMyInterfaceFactoryA>; Then I resolve the factory and create an interface, it works ok. But I would like a second factory that will always give ParamC a constant value, e.g. True I tried this: TMyInterfaceFactoryB = reference to function(ParamA : string; ParamB : Integer) : IMyInterface; but I get error when resolving: 'Unsatisfied constructor on type TMyClass' How to declare and register such a factory? A … Jacek Laskowski +Stefan Glienke Of course you were right, everything works correctly. The problem for me was the incomplete registration and “losing” by the container of one of the constructors. Is it possible to force Spring to report an unknown, unregistered type used in the constructors? At the moment, the report is poor, with a complex hierarchy of classes and extensive constructors a lot of time is lost in searching for missing registrations :-(Eg.classes:TUnknownClass = class end;TExampleClass = class public constructor Create(aUnknown : TUnknownClass); end;{$M+} TExampleClassFactory = reference to function : TExampleClass; {$M-}registrations:aContainer.RegisterType<TExampleClass>; // >>>>>> missing TUnknownClass type registration aContainer.RegisterFactory<TExampleClassFactory>;usage: var lExample: TExampleClass; begin lExample := aExampleClassFactory(); and error: 'Unsatisfied constructor on type: ss.Framework.Base.SafeQueryProvider.TExampleClass' There is only information WHERE is missing and not WHAT. Would it be possible to detect the lack of TUnknownClass registration during the TExampleClass class registration and add this fact in the message? I lost a few hours to look for such details, and if Spring were to report it would be wonderful :-) Stefan Glienke “Would it be possible to detect the lack of TUnknownClass registration during the TExampleClass class registration and add this fact in the message?” No, because order of registration does not have to be like that, can easily register TUnknownClass after that or provide it by some other way. Proper ctor to be called are currently determined at resolve time. Even when calling container.Build it currently is not possible to determine that because type registrations are only processed after each other. For that to work at that point it would need to do a second run checking and selecting ctors after all types are known to the container. It even is something that I want for quite some time because that would improve resolve performance significantly because it can already build a plan of what to create without determining that over and over. What we are doing at work is putting some information out via the ILogger interface inside the type resolver so we can see in the log what ctors it inspects and which it picks (or does not). That being said I have been planning quite some changes for 1.3 that also touch on this topic because once your object graph gets huge using the container requires some way of diagnostic possibilities. But the curse of the current flexibility of the container makes this not so easy as there are so many corner cases and exceptional use cases that are all valid that I don’t want to break (or at least be aware of to put them into some breaking change list and provide alternative ways to solve the task) Jacek Laskowski +Stefan Glienke Ok, it does not have to be checked at the registration stage or even Build. It would be enough for the resolver, in the place where it analyzes the available constructors, to detect the type that is not registered, and then that this information would be passed higher and if an exception occurs, its message would contain information about this unknown type. In general, I would like to get info about the fact that the resolver does not know the TUnknownClass type when trying to create a TExampleClass object. That’s all. I know it’s not trivial :-) Thanks for you works, I waiting for S4D 1.3 Q: [WayBack] Spring4D IoC and specific singleton… – Jacek Laskowski – Google+ Spring4D IoC and specific singleton I have a generic interface to write data to the database: IDBStorer. This interface can write data to any pre-defined table (generates inserts and updates). I would like the group of objects that saves, for example, orders, to use one instance of this interface, but configured to store orders. Completely in other place, another group of objects saves, for example, car routes, also uses the IDBStorer interface, but with a completely different configuration. Therefore, I would need to resolve the interface from the factory using some type of “order” or “route” and to get the same instance for each “route” request, but different than when I resolve for “order”. Something like this: OrdersStorer := Container.Resolve<IDBStorer>.NamedSingleton('orders'); RouteStorer := Container.Resolve<IDBStorer>.NamedSingleton('route'); or better by factory: TStorerFactory = reference to function(aStorerIdentifier : string) : IDBStorer; Container.RegisterFactory<TStorerFactory>.AsNamedSingleton; OrderStorer := StorerFactory('orders'); OrderStorer2 := StorerFactory('orders'); RouteStorer := StorerFactory('route'); and I get one instance IDBStorer per unique string, so OrderStorer is equal in this case OrderStorer2 (because resolved by this same unique identifier ‘orders’) Is it possible? A Stefan Glienke I already answered your question on the forum. If you dont like the multiple registrations per “key” for the singletons then use the most obvious: a dictionary where you put in your instances per key and fetch them from there which you can abstract just fine with a factory(key Jacek Laskowski It looks like I have to write my own LifeTimeManager and register the type with this manager, is this a good clue? Jacek Laskowski +Stefan Glienke Where should I put this dictionary? I would like to use the benefits of Spring and entrust him with managing such things. Perhaps in LifetimeManager, similar to TSingletonPerThreadLifetimeManager? Stefan Glienke+1 Do whatever you want but a DI container is not a multipurpose swiss army knife design pattern. It is for creating object graphs. And your object graph by definition has 2 (or more) different instances of IDBStorer instances for a given key (string, or type of object it handles or whatever). The definition of your object graph is what happens in the registrations. As you can see in my example that I gave you I am exactly doing that “using the benefits”. I am putting 2 different registrations (in the example they look the same except their name). Now you could even imagine that the one gets also other dependencies passed than the second (maybe the one needs a TOrderValidator passed as IValidator and the other needs a TRoutesValidator – can easily put that in the registrations and model your object graph). Or one day you find out that you cannot use the same implementation at all for those two and you can easily change that by switching the registrations for one or both to not use the same implementing class but different ones. Everything else is hack that will fall onto your feet sooner or later. Jacek Laskowski+1 +Stefan Glienke Yes! I calmly rethinked about what you wrote, you are absolutely right! Yesterday I thought I was not understood, but it is I who complicate the simple things very much. I forgot about KISS. Thanks for comment. Jacek Laskowski+1 +Stefan Glienke One more question: I do not want to use the IDBStorer interface directly in the constructors of other classes, but I want to use the factory method. How to declare and register a factory to get the same effect? TDBFactory = reference to function (aSingletonIdentifier: string): IDBstorer; Stefan Glienke+1 RegisterInstance<TDBFactory>(function(aSingletonIdentifier: string): IDBStorer begin Result := container.Resolve<IDBStorer>(aSingletonIdentifier); end); A. Bouchez If you use singletons, why not just use a global variable? I don’t like singletons for sure. ;) Stefan Glienke+4 +A. Bouchez Singleton in DI means not the same as in the design pattern. It means that it is ensured that there is only one instance every time I ask for this as a dependency but not a new instance each time. And the subtle but important difference is that the singletoness is not baked into the class itself but controlled by the container and how you configure things. A. Bouchez+1 +Stefan Glienke You are right. I remember now – I already made this confusion some time ago… same naming is IMHO wrong. “Shared” or “Common” could be less confusing for sure. In our framework we use “sicShared” for such an instance livetime. Stefan Glienke+1 +A. Bouchez I did not invent the naming but it is called like that in most DI frameworks. Being really pedantic though I would say that it is an implementation detail of the pattern that is the bad thing and when you do DI the implementation of it is good as it is not coupled to the core responsibility of the class and not part of the class itself but of the mechanism that creates them. The Spring4D forum thread: [Archive.is] Concrete instance of singleton – like a multiple singleton? – Google Groups Jacek Laskowski I have an ISomething interface. I would like a certain group of objects to use a specific instance of ISomething (A), and another group of another ISomething (B) instance. So there is one interface, one implementation, but two instances of this interface are created, which many other objects use. How to register this interface (maybe with identifier?) in the container and how to resolve instance A or B via the factory method? Philipp Schäfer As far as I am aware, you can only name the registration and overwrite the resolving mechanich of each and every depend type (by specifying the named value and nil for the other constructor parameters). This specification is made during the registration phase. I do not recall the exact method name. This will be improved in upcoming versions. Another possibly more simple approach might be to derive two interfaces from ISomething with no further method. And register implementation A and B as singletons to these derived interfaces. If you want to dive really deep you could influence the resolving process by a container extension. We do this for something else in one of our projects. This takes probably the most effort and might be subject to changes in updates. Sorry that I talk mostly out of my head here, as I am on mobile only. {$APPTYPE CONSOLE}   uses   Spring.Container,   System.SysUtils;   type   ISomething = interface     ['{829E67EE-EA29-4D90-8CD3-558DB168F150}']   end;     TSomething = class(TInterfacedObject, ISomething)   end;     TCompBase = class   private     fSomething: ISomething;   public     constructor Create(const something: ISomething);     property Something: ISomething read fSomething;   end;     TCompA = class(TCompBase);   TCompB = class(TCompBase);   TCompC = class(TCompBase);   constructor TCompBase.Create(const something: ISomething); begin   fSomething := something; end;   var   a,b,c: TCompBase; begin   GlobalContainer.RegisterType<ISomething, TSomething>('somethingA').AsSingleton;   GlobalContainer.RegisterType<ISomething, TSomething>('somethingB').AsSingleton;   GlobalContainer.RegisterType<TCompA>.InjectConstructor(['somethingA']);   GlobalContainer.RegisterType<TCompB>.InjectConstructor(['somethingB']);   GlobalContainer.RegisterType<TCompC>.InjectConstructor(['somethingB']);   GlobalContainer.Build;   a := GlobalContainer.Resolve<TCompA>;   b := GlobalContainer.Resolve<TCompB>;   c := GlobalContainer.Resolve<TCompC>;   Writeln(a.Something = b.Something);   Writeln(a.Something = c.Something);   Writeln(b.Something = c.Something); end. Jacek Laskowski I can’t do this on two interfaces or two registrations. In fact, these groups of objects using one singleton can be much more. I will describe it specifically.I have a generic interface to write data to the database: IDBStorer. This interface can write data to any pre-defined table (generates inserts and updates). I would like a group of objects that saves, for example, orders, to use one instance of this interface, but configured to store orders. Completely in other place, another group of objects saves, for example, car routes, also uses the IDBStorer interface, but with a completely different configuration.Therefore, I would need to resolve the interface from the factory using some type of “order” or “route” and to get the same instance for each “route”, but different than when I resolve for “order”.Something like:OrdersStorer := Container.Resolve<IDBStorer>.NamedSingleton('orders'); RouteStorer := Container.Resolve<IDBStorer>.NamedSingleton('route');or better by factory:TStorerFactory = reference to function(aStorerIdentifier : string) : IDBStorer; Container.RegisterFactory<TStorerFactory>.AsNamedSingleton;OrderStorer := StorerFactory('orders'); RouteStorer := StorerFactory('route');and I get one instance IDBStorer per unique string.Is possible?     –jeroen
Read More

FMX Line Angle Demo

 A simple demo showing how to create a GUI with FMX to let the user draw two intersecting lines and then compute and show the angle between the two lines. The use has to click on 3 points: the point where the lines intersect, the point where the first line (red) ends and the point where the second line (green) ends. The user interface is updated in real-time following mouse movements. Full
Read More

TMS WEB Core for Visual Studio Code v1.1 released

We are excited to announce the immediate availability of TMS WEB Core for Visual Studio Code v1.1 that now enables developing cross-platform Electron desktop apps and PWA’s. This is a new milestone in the development of RAD component Object Pascal language based web development. The key differentiators of TMS WEB Core for Visual Studio Code are:

  • RAD component based development from the free Visual Studio Code IDE
  • RAD designer using web technology, enabling live, wysiwyg design-time rendering
  • Development directly from Windows, macOS and Linux desktop machine
  • Rich eco system of web related development extensions for the IDE
  • Modern IDE with multiview editing, direct high-DPI/retina support

With TMS WEB Core for Visual Studio Code v1.1, we complete the three targets that TMS WEB Core offers. In the new v1.1, we introduce next to classic web client applications the Electron application target and PWA target.


The first new target is Electron applications. Electron is a framework that enables to create compiled applications for Windows, macOS and Linux using web technology for rendering and execution of the application. The Electron framework is fully cross platform and at application code level there is nothing to take care off in terms of different platforms. Note that it is thanks to the Electron framework that the hugely popular Visual Studio Code IDE runs on Windows, macOS and Linux directly (and recently also Raspberry Pi target was added recently).
As Electron applications run as executables directly on the desktop operating system, this means that extra functionality such as direct local file access, access to all kinds of operating system dialogs (File Open, File Save), toast messages, taskbar notifications, drag & drop support and more … is available. For a TMS WEB Core developer, this is offered through Electron specific components. For direct local or network database access, there are also two dataset components for direct access to mySQL and PostgreSQL.


The other new target is Progressive web applications. PWA is perhaps the most promising direction for web client application development. A PWA is a responsive web application that can run offline and can be installed on mobile devices (iOS/Android) and also in desktop browsers like Chrome, Firefox, Edge Chromium. After install, your PWA can be started from an icon on the home screen as if it is a native cross platform application. It can run offline and when online, it will still update itself. So, as a developer there are zero concerns about deployment.
With TMS WEB Core for Visual Studio Code v1.1, you simply choose a PWA type from the projects repository and it automatically generates all necessary files for creating a PWA. Everything available for classic web applications and that you learned about it is applicable for the PWA project type.


With v1.1, the TMS WEB Core target support is completed. As far as core framework is concerned and the target support, TMS WEB Core for Visual Studio Code is now on par with TMS WEB Core on Delphi. Best of all, the projects are 100% compatible, so Visual Studio Code developers can decide to start using Delphi and continue working on a project and vice versa. Or a Delphi developer on Windows can exchange projects with a colleague using Visual Studio Code on macOS, etc…


TMS WEB Core for Visual Studio Code is available from the Microsoft Visual Studio Code marketplace, so, if you had installed it, it will auto-update. It is also available for manual install as trial version from https://www.tmssoftware.com/site/tmswebcorevsc.asp and for active customers after login on our website under “My Products”.

What’s next

The next big step is installable third party component support. At this moment, 3rd party components can be created and used at runtime but there is not yet support for installing these into the IDE, have the components on the tool palette and see the components at design-time. Work on this is already underway and in our internal development versions, we can confirm that the entire TMS FNC component range runs happily within the Visual Studio Code IDE. Our team works as hard as we can on reaching also this milestone. Stay tuned for this and even more exciting developments happening in the labs right now as we unwrap these!

Read More

Read More

REST API and Delphi error: Required OAuth credentials not provided

I need to implement a REST API in FireMonkey to get some information, but I'm not sure how I can do it. The REST API uses OAuth2, I have the ACESS_TOKEN but is not working <ams:fault xmlns:ams="http://wso2.org/apimanager/security"><ams:code>900902</ams:code><ams:message>Missing Credentials</ams:message><ams:description>Required OAuth credentials not provided. Make sure your API invocation call has a header: "Authorization: Bearer ACCESS_TOKEN"</ams:description></ams:fault> var LClient: TRESTClient; LRequest: TRESTRequest; LResponse: TRESTResponse; begin LClient := TRESTClient.Create('https://apigateway.serpro.gov.br/consulta-cnpj- df/v1/cnpj/99999999999999'); try LRequest := TRESTRequest.Create(LClient); try LResponse := TRESTResponse.Create(LClient); try LRequest.Client := LClient; LRequest.Response := LResponse; LRequest.Accept:='application/json'; LRequest.Params.AddHeader('Authorization', 'Bearer 6315a3c9c2e4bb2e0816da132828f269'); LRequest.Method := rmGET; LRequest.Execute; Memo1.Clear; Memo1.Lines.Add(IntToStr(LResponse.StatusCode) + ' / ' + LResponse.StatusText); Memo1.Lines.Add(LResponse.Headers.Text); Memo1.Lines.Add('--------------------------------------------------------------'); Memo1.Lines.Add(LResponse.Content); finally LResponse.Free; end; finally LRequest.Free; end; finally LClient.Free; end; end; Can someone help me?
Read More

FMX TCameraComponent with IFMXCameraService bug

In the app I need to scan a Barcode, then access the camera to take photos followed by further Barcode scanning. Therefore, I use both the TCameraComponent and IFMXCameraService interface. The problem occurs once I start the TCameraComponent (for scanning a Barcode code), then deactivate it and take a photo... when i go back to TCameraComponent i get error: raised exception class EJNIException with message 'java.lang.RuntimeException: getParameters failed (empty parameters)'. An important clarification: if you first get a photo, and then open the barcode scanner, there is no error. The error appears if you open the barcode scanner at least once, close it, take a photo, and open the scanner again. Start scanner: if ( Length( AGrantResults ) = 1 ) and ( AGrantResults[ 0 ] = TPermissionStatus.Granted ) then begin SetCaptureSetting(); FBuffer.Clear( TAlphaColors.White ); FActive := True; LabelFPS.Text := 'Start capturing...'; FCamera.Active := True; StartStopWatch(); lblScanning.Text := 'Scan On'; FaLblScanning.Enabled := True; end else Showmessage( '' ); Stop scanner: lblScanning.Text := 'Scan Off'; FaLblScanning.Enabled := False; FActive := False; DisplaySlowWarning(False); FCamera.Active := False; LabelFPS.Text := ''; Take photo: var Params: TParamsPhotoQuery; Service: IFMXCameraService; begin if TPlatformServices.Current.SupportsPlatformService( IFMXCameraService, Service ) then begin Params.Editable := False; Params.NeedSaveToAlbum := False; Params.RequiredResolution := TSize.Create( 1080, 1920 ); Params.OnDidFinishTaking := DoDidFinish; Service.TakePhoto( btnTakePhoto, Params ); end else ShowMessage('This device does not support the camera service'); I tried making Service global, and using Service := nil after taking photo, did not help.
Read More

Register new media codec in FMX media player in C++ Builder

When I try to play an .mp4 video file using the TMediaPlayer FMX control in C++Builder, it reports an error: unsupported media file So, I tried to register an MP4 codec in FMX's Media Codec Manager using the below code: TMediaCodecManager::RegisterMediaCodecClass(".mp4", "mp4", TMediaType::Video, TWindowsMediaCodec); But it also reporte an error: TWindowsMediaCodec is undefined symbol How do I register a new codec in FMX's Media Player in C++Builder?
Read More

Delphi with new M1 chip (instead of Intel chip) [closed]

Will Apple's M1 chip affect anything for Delphi development in iOS/MacOS? My guess is since Delphi is sending code over to XCode to do final executable (?? not sure if I'm correct), it should be ok to buy a M1-chip to do iOS & MacOS apps ? and since native iOS/iPad apps can run directly on M1-chips, I suppose it means we don't need an iOS emulator on MacOS in future? Will we need an update for Delphi to send iOS app to run on MacOS directly (instead of emulator)? Question : will current 10.4.x Delphi work with M1 CPU? - based on Dave's answer, it is no, as it requires a new compiler.
Read More

Android memory corruption

I have a very strange bug on Android that I can't explain. Most of the time, my app (made in Delphi with FireMonkey) ends with External exception xx or Access violation at address xxx, accessing address 0000000x and I can't explain why. The exceptions appear in different places of my software, and at very unexpected times. For example, the last error log I receive just now is this one: libapp.so $0000007D91A61548 Grijjy.Errorreporting.TgoExceptionReporter.GlobalGetExceptionStackInfo(TExceptionRecord*) + 128 libapp.so $0000007D911E5220 Sysutils.Exception.RaisingException(TExceptionRecord*) + 52 libapp.so $0000007D9120F814 Sysutils.RaiseExceptObject(TExceptionRecord*) + 64 libapp.so $0000007D911C57A0 _RaiseAtExcept(TObject*, Pointer) + 100 libapp.so $0000007D911E42EC Internal.Excutils.SignalConverter(NativeUInt, NativeUInt, NativeUInt) + 56 libapp.so $0000007D911C3B2C _IntfClear(IInterface&) + 68 libapp.so $0000007D91256C90 Rtti.TRttiContext.Free() + 20 libapp.so $0000007D91349AB8 Androidapi.Jnibridge.dispatchToNative(JNINativeInterface**, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Androidapi.Jni._JNIObject*, Int64) + 980 But as I say, most of the time those bugs appear in completely different places, like for example: libapp.so $0000007C76C0AC50 Grijjy.Errorreporting.TgoExceptionReporter.GlobalGetExceptionStackInfo(TExceptionRecord*) + 128 libapp.so $0000007C7638FC80 Sysutils.Exception.RaisingException(TExceptionRecord*) + 52 libapp.so $0000007C763BA274 Sysutils.RaiseExceptObject(TExceptionRecord*) + 64 libapp.so $0000007C76370200 _RaiseAtExcept(TObject*, Pointer) + 100 libapp.so $0000007C7638ED4C Internal.Excutils.SignalConverter(NativeUInt, NativeUInt, NativeUInt) + 56 libapp.so $0000007C769D9FE8 Fmx.Types.ArrangeControl(Fmx.Types.IAlignableObject, Fmx.Types.TAlignLayout, Single, Single, Single, Single, var Types.TRectF) + 112 libapp.so $0000007C769DA824 Fmx.Types.AlignObjects(Fmx.Types.TFmxObject*, Fmx.Types.TBounds*, Single, Single, var Single, var Single, var Boolean).DoAlign(Pointer, Fmx.Types.TAlignLayout) + 556 libapp.so $0000007C769DAABC Fmx.Types.AlignObjects(Fmx.Types.TFmxObject*, Fmx.Types.TBounds*, Single, Single, var Single, var Single, var Boolean) + 508 libapp.so $0000007C76A4DC60 Fmx.Forms.TCustomForm.Realign() + 168 libapp.so $0000007C76A49A84 Fmx.Forms.TCommonCustomForm.Updated() + 36 libapp.so $0000007C76A499D0 Fmx.Forms.TCommonCustomForm.EndUpdate() + 252 libapp.so $0000007C76A4EA94 Fmx.Forms.TCustomForm.EndUpdate() + 20 libapp.so $0000007C76E06564 main.TMainForm.ShowFrame(base.TBaseFrame*, Boolean, definition.TShowFrameTransition) + 3528 libapp.so $0000007C76E06F28 main.TMainForm.ShowPreviousFrame() + 1820 libapp.so $0000007C76DFFDD4 main.TMainForm.FormKeyUp(TObject*, var Word, var Char, set of Classes.System_Classes__1) + 500 libapp.so $0000007C76A48E74 Fmx.Forms.TCommonCustomForm.KeyUp(var Word, var Char, set of Classes.System_Classes__1) + 104 libapp.so $0000007C7698BAE0 Fmx.Platform.Ui.Android.TAndroidTextInputManager.KeyUp(var Word, var Char, set of Classes.System_Classes__1, Boolean) + 72 libapp.so $0000007C76987618 Fmx.Platform.Ui.Android.TAndroidTextInputManager.HandleAndroidKeyEvent(AInputEvent*) + 976 libapp.so $0000007C769AF36C Fmx.Platform.Android.TPlatformAndroid.HandleAndroidInputEvent(Androidapi.Appglue.TAndroidApplicationGlue*, AInputEvent*) + 64 libapp.so $0000007C76648D90 Androidapi.Appglue.TAndroidApplicationGlue.InputEventHandler(Integer, Integer, Pointer) + 184 libutils.so $0000007D6F73AD90 android::Looper::pollInner(int) + 860 libutils.so $0000007D6F73A998 android::Looper::pollOnce(int, int*, int*, void**) + 60 It's very rare (around 1 time every 500 launches), always at different places. I doubt it's an error in my code. I start to think that maybe memory is becoming corrupted? For example, my app sends some JSON to my server, and this is via a Java library (so no Delphi code involved here) and sometimes I receive this JSON: positions=[{"latitude":8.620783,"longitude":1.4476126,"accuracy":13.26200008392334},"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"]} This \u0000\u0000\u0000...\u0000\u0000 makes me think that something starts to be a total mess in my app, so maybe the memory? The code that generate this JSON is quite simple: JSONObject newNode = new JSONObject(); newNode.put("latitude", location.getLatitude()); // double newNode.put("longitude", location.getLongitude()); // double newNode.put("accuracy", location.getAccuracy()); // double Note: it appears on many different devices (Huawai, Samsung, etc). So, is their something that can explain this behavior? Is it possible that the memory used by my app is lost or wiped out? Most important, how can I find out where the problem is exactly?
Read More