Subscribe: marcocantu.blog
http://blog.marcocantu.com/blog_atom.xmldata
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
applications  build  code  controls  delphi  embarcadero  end  free  json  new  object  patch  rad  resources  set  support  vcl 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: marcocantu.blog

marcocantu.blog



Techie Italian Blogging on Delphi and More



Updated: 2018-02-20T08:36:13.855Z

 



RAD Studio 10.2.2 Tokyo February 2018 Patch Re-Released

2018-02-20T08:36:13.855Z

We have released (after an initial glitch) a patch for Delphi and C++Builder 10.2.2 Tokyo covering a critical Android animation issue and some RTL interface compatibility improvements

Last week, Embarcadero released a patch for Tokyo 10.2.2, focused on Android and RTL improvements. What happened is that Windows would not always ask for execution with admin account (on systems with active User Account Control) and could end up copying the replacement files in a wrong location. It did affect a few of the developers who tried it, so we pulled it, fixed the installer and now re-issued the patch.

If you are a registered user of Tokyo (or have a license for it), you can find it at https://cc.embarcadero.com/item/30819.

There is no change in the content on the patch, so if you already installed it successfully, there is no need to repeat the process. On the other hand, if your installation got broken, we have provided an alternative ZIP-based option (in the same download page). We have already sent it to developers who had got in trouble, but might not have reached everyone.

As for the content, the main fix is the Android animations and tab animation issue. These have been addressed. There are still cases in code where the combination of called to Application.ProcessMessages and timers might get you in trouble. I'll blog more information ASAP, but the general recommendation is to use threads rather than timers for background processing -- an all platforms, although in Windows that coding style can be used.

 

Updated Notice: Only for 10.2.2 Build 2004 

We had a notice in the download page, but better repeat it here. The patch is only for the second build of 10.2.2 we released, build 2004. If you have the previous build (which had compatibility problems with third party packages) don't install the patch. Either wait for a future update (if you don't specifically need the fixes the patch provides) or install build 2004 first. The link to 2004 installer is in the patch download page.

(image)



Delphi 23 and Delphi 10.2.3

2018-02-14T21:05:53.177Z

Today is Delphi's 23rd birthday and Embarcadero just announced version 10.2.3. Coincidence? ;-)

Today is Delphi's 23rd birthday. The product was launched on Valentine day in 1995 in San Francisco (and I had the luck to be there, as I covered in the past). 23 years is a lot of time for people. It is a incredibly long time for technologies. It is hard to find a language, framework and IDE from 23 years ago you can use to build todays's and tomorrow's software. Of course, the IDE, language and frameworks have evolved and keep evolving -- developers using them can modernize their apps without a full rewrite.

In this 23 years, millions of developers and have used Delphi to build millions of applications, and applications used by millions of users. The most used Delphi application ever build is probably Skype for Windows. But it has been used to build applications worth millions in sales and moving millions in financial markets. And Delphi is still used to day to maintain those applications and create new ones in industrial, financial, health, travel, and sport fields (among others)... including mobile apps for its birthday. Or to run a miniature airport.

In these 23 years the product has changed a lot (Hey, I've changed a lot from the picture in the link above!), Below you can find a comparison of Delphi 1 running on a VM and Delphi 10.2.2 (with dark theme) running on the same machine. It is not a Photoshop, it is an actual screenshot!

(image) Both versions of the IDE have a VCL application with a Button and the Caption property highlighted in the Object Inspector. I didnt' include the about bos of 10.2.2 (as I was trying to do) because it is a little too big. One of these days I'll make a parallel video of working on both. But you know what? Most applications you build in Delphi 1 can be recompiled with few changes in the 23 year later version. Well, as long as you don't use pointers, as Delphi 1 had 16 bit pointers (ugh!). Of course, most applications you write in todays product don't have a chance to run in the older sibling.

Speaking of today, Embarcadero (and the PM team I'm part of) just announced some more plans for this year, and the plan does include the coming release of an additional quality focused update for 10.2 Tokyo, 10.2.3. Now 10 x 2 + 3 is in fact 23. Or Delphi 10 version 2.3. We have a lot in the works for the next mayor release, but also want to keep improving on the quality of Tokyo and release it as soon as possible.

What else can I say? Just invite to you watch Jim Mckeeth great "23 years" Why I Love Delphi video.

(image)



My New RTTI in Delphi Class on Embarcadero Academy

2018-02-05T09:43:35.755Z

Last week I published a new Delphi language training class focused on RTTI on the Embarcadero Academy web site, and the class has also been added to the "Master Modern Delphi Language" course bundle.

As you might remember, I'm helping building the Delphi curricula on the Embarcadero Academy web site. My focus so far has been on the Delphi language, while other tackle VCL and other areas, or other languages and tools. Last week I completed my set of classes on the Modern Delphi language (Interfaces, Generics, Anonymous Methods) with a class on reflection and RTTI. You can buy each of these classes separately (price vary depending on the length) or buy the complete bundle with over 8 hours of content.

The class on reflection and RTTI has a lot of information on the modern RTTI (compared to the classic one), covers the RTTI unit, the TValue record, the use of attributes and much more. And for those who already purchased the Modern Delphi bundle in th past, the new class has been added to their account for free!

(image)

(image)



Try-Finally Blocks for Protecting Multiple Resources in Delphi

2018-01-26T16:52:57.745Z

In the Delphi language resource allocations and use is generally protected with try/finally blocks. But what's the best practice for protecting multiple resources? We've had some internal discussions and I'd like to share some of the considerations. The Delphi language shares with many others a standard resource allocation pattern to make sure that in case of an exception the resources is properly released. Resources in this context are memory objects, files, operating system objects and handles, and the like. In Delphi, compared to other languages with a garbage collector, the relevance increased by memory management considerations. Protecting a Single Object In the most simple cases, you'd write code like: allocate resource try use resource finally free resource end; A more specific example would be like: A1 := TTest.Create; try A1.DoSomething; finally A1.Free; end; So far, so good. Notice that is an error happen during the constructor execution, Delphi will automatically execute the destructor for the partially initialized object (but this could be a topic for another blog post). Protecting Two Objects: How NOT to Write the Code The issue I want to focus on is how to write the same type of code if you need to allocate and dispose two resources. Here there are multiple options. What you shouldn't do (but is fairly common) is to write: A1 := TTest.Create; A2 := TTest.Create; try A1.DoSomething; A2.DoSomething (A1); finally A2.Free; A1.Free; end; The issue with this code is that in case the creation of A2 fails (and there could be many reasons), the A1 object would remain in memory. Simply pushing the second allocation within the try block is also not good: A1 := TTest.Create; try A2 := TTest.Create; A1.DoSomething; A2.DoSomething (a); finally A2.Free; A1.Free; end; With this code in case of a failure in object A2 constructor call, the finally block will try to Free an uninitialized object (the default value of a local object reference is undefined). This is why a possible solution is to set A2 to nil at the beginning -- as calling Free on a nil object has no effect. Or set all object reference to nil for simplicity and uniformity. Or write two nested try blocks to protect each of the resources. Protecting Two Objects: A Tale of Three Solutions This long introduction brings us to the point of this blog post. There are at least 3 different correct solution for the issue of protecting two resources in the same code block, as I just mentioned. Here are the three solutions in an image I "borrowed" from one of our RAD Studio R&D architects, Bruneau Babet. Provided they are all correct in terms of proper resource management in all scenarios, which are the advantages and disadvantages of these 3 solutions? What is important to consider is that the 2 resources could be 3, or 4 or half a dozen.  Which One to Pick? The first solution with the nested try blocks fairly clean but more verbose (more lines of code) and has additional nesting that could become an annoyance with multiple resources. Also, there is a runtime cost associated with try blocks, clearly limited but not zero.  The second solution has the least amount of lines of code code and the least amount of runtime cost. The only additional is setting A2 to nil. The code remains readable also with many resources. However, the code is "unbalanced" and it might be slightly confusing. The third solution goes in the same direction, but it adds one extra technically useless assignment to nil (for A1), offering the advantage of being cleaner and more balanced, and likely more readable after all. So what's the best solution? This is really hard to tell,. I personally mostly used #1 in my books, but at Embarcadero we tend to prefer the cleaner and faster ones (that is, #2 or #3) for library code. Interested in your opinions, of course. [...]



HTTP Protocol Related Improvements in Delphi 10.2.2

2018-01-24T15:11:20.258Z

In Delphi and C++Builder Tokyo 10.2.2 we have added a number of features to the HTTP client and REST client libraries. Here is a summary.

The new features for the HTTP client library offer more flexibility and options in terms of protocol and standards support. 

Better Secure Protocols Support

The first change is the improved support for security protocols. In the past it wasn't possible to specify the required security protocols (TLS1.1, TLS1.2, etc.) for an HTTP request. We have added a new enumeration, THTTPSecureProtocol with the values (SSL2, SSL3, TLS1, TLS11, TLS12). THPPTClient and related classes have now a SecureProtocols property which is a set based on that enumeration.

The property (available only at run-time) controls which security protocols to use and it is currently implemented only for Windows. This was requested in our Quality Portal at https://quality.embarcadero.com/browse/RSP-18713

HTTP Redirect Improvements

Another set of improvements is in the way the HTTP client library handles redirects. There is a new RedirectsWithGET runtime property offering another set of options, this time based on the following enumeration:

THTTPRedirectWithGET = (Post301, Post302, Post303, Post307, Post308, 
  Put301, Put302, Put303, Put307, Put308, Delete301, Delete302, 
  Delete303, Delete307, Delete308);

The property controls which request method and response status must be redirected using GET method and it was reported in several entries in QP, including https://quality.embarcadero.com/browse/RSP-14671.

New REST Client Events OnNeedClientCert and OnAuthEvent

These events corresponds to their HTTPClient counterparts and are now surfaces at a higher level:

TRESTClient.OnNeedClientCertificate: TNeedClientCertificateEvent
TRESTClient.OnAuthEvent: TCredentialAuthEvent

This was requested in https://quality.embarcadero.com/browse/RSP-15857

MIME Name Helper

We added a function that to the TEncoding support, which returns the encoding MIME for a speficied encoding:

function GetEncodingMimeName(AEncoding: TEncoding): string;

Changed TIniFile Behaviour

This one is totally unrelated, beside the fact it was also done in 10.2.2. The Ini File behavior was platform specific, not is it platform independent. On Windows, TIniFile ReadString ignores the case of Key parameter. On Linux, the ReadString call was case sensitive, leading to issues when migrating code and configuration files. Now by default TIniFile content structure (not the actual values) is treated in a case-insensitive way on all supported platforms.

(image)



My Year in Cities 2017

2017-12-31T16:45:55.956Z

Following a long tradition of this blog, dating back to 2006 (and continued in each of the following years), here is my year 2017 seen through the cities I've been to.

This is my end-of-the-year blog post listing places I've visited in 2017 for at least one night (plus some relevant daily trips, marked with an asterisk), in chronological order. At times, the reason for the trip is listed: 

Torino (Italy)*

Trento (Italy)*

Sydney (Australia)

Brisbane (Australia), ADUG conference

Melbourne (Australia), ADUG conference

Altdorf (Switzerland)

Sprendlingen (Germany)

Nieuwegein (Netherlands)

Amsterdam (Netherlands)

Texel Island (Netherlands)

Nieuw Vennep (Netherlands)

Rotterdam (Netherlands)

Bruxelles (Belgium)

Vincey (France)

Colmar (France)

Berlin (Germany)

Zegrze (Poland), Delphi conference

Pisa (Italy)*

Frascati (Italy), ITDevCon conference

Koln (Germany), EKON conference

Viareggio (Italy)

Lucca (Italy)*, Lucca Comics event

Katowice (Poland)*

Ravenna (Italy)*

While I've been traveling a bit, my trips this year have been limited to Europe, plus a long trip to Australia. Planning a trip to the US within a few weeks, and spend some time booking flights today. Good sign.  

Have a great 2018 full of health and happiness (and traveling!).

(image)



Moving DNS, Some Hiccups Expected

2017-12-18T17:48:44.316Z

Site and blog might have hiccups in the coming days over DNS transition.

Not much to add. I'm (finally) changing my registrar and DNS provider. Hope everything goes smootly, but it might be that the site and blog are not working in the few coming days. The physical server is not moving, so there should be no big trouble.

(image)



DataSet Mapping to JSON for JavaScript client support in RAD Studio 10.2.2

2017-12-15T10:45:40.815Z

In the latest release of Delphi and C++Builder, Embarcadero has added a new component to the FireDAC BatchMove architecture, to support generating JSON data from database tables, in an easy and flexible way. RAD Studio has offered support for JSON in different ways and for a long time. From the JSON system unit (originally part of the DBX space) to the old DataSnap table mapping (also via DBX) and to FireDAC tables to JSON mapping, there are many ways to interact with JSON data structures. However, until the most recent release, we lacked a way to map a dataset to a custom JSON structure -- the FireDAC JSON support produces a FireDAC specific structure, with meta data and record status information. While this is a gap we already wanted to fill, it become more important to address it now that we are pushing RAD Server (a free deployment license is included with 10.2.2 Enterprise and above) and use it as a backend for ExtJS applications. As you can read in my blog post Implementing AJAX and JSONP Support in RAD Server for ExtJS, while this works the dataset mapping to JSON required writing custom code. Our first step in simplifying the use of Delphi as a backend for JavaScript applications is offering a better way to produce the JSON data from a database table. While we have build this support for the scenario of using RAD Server, FireDAC, and ExtJS, the same component and technology can be used for any web service architecture written in Delphi and C++Builder (even pure and simple WebBroker), any dataset other than FireDAC, and any JavaScript client. It is a completely open and a fairly flexible solution. But it certainly works great for our specific scenario! A VCL Application I'll describe the solution using two demos. The first is a plain VCL application. while the second will be a RAD Server package. This highlights the fact that the solution is fairly general. In the first demo, I have the following components on a form (I know, I should have used a data module...): This is the configuration of the components: object EmployeeConnection: TFDConnection Params.Strings = ( 'ConnectionDef=EMPLOYEE') end object EmployeeTable: TFDQuery Connection = EmployeeConnection SQL.Strings = ( 'SELECT * FROM EMPLOYEE') end object FDBatchMoveDataSetReader1: TFDBatchMoveDataSetReader DataSet = EmployeeTable end object FDBatchMoveJSONWriter1: TFDBatchMoveJSONWriter DataDef.Fields = end object FDBatchMove1: TFDBatchMove Reader = FDBatchMoveDataSetReader1 Writer = FDBatchMoveJSONWriter1 Mappings = LogFileName = 'Data.log' end With this configuration in place, all you need to do to produce the JSON is connect the output to the JSON writer and execute the batch move operation. In this case I've used a stream: procedure TForm5.Button1Click(Sender: TObject); var sstr: TStringStream; begin sstr := TStringStream.Create; try EmployeeTable.Active := True; FDBatchMoveJSONWriter1.Stream := sstr; FDBatchMove1.Execute; ShowMessage (sstr.DataString); finally sstr.Free; end; end; Other options are assigning to the writer for the output a JSONWriter (as I'll show shortly) or a JSONArray. A RAD Server Web Service For the second demo, the RAD Server demo, I've used the same set of components with the same configuration. In this cases I've added to an EMS package an "employee" resource, and implemented its get operation with the following stream-based code: procedure TEmployeeResource1.Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); var mStream: TMemoryStream; begin mStream := TMemoryStream.Create; AResponse.Body.SetStream(mStream,'application/json', True); FDBatchMoveJSONWriter1.Stream := mStrea[...]



New VCL Panels in Delphi 10.2.2

2017-12-14T21:47:58.632Z

Along with the picker controls I described yesterday, the VCL in Delphi 10.2.2 has two additional panel controls: TCardPanel and TStackPanel.

With the need to support more screen resolutions, while creating nice looking user interfaces and pleasant user experiences, we think it is important to offer additional ways to build the UI of your VCL applications. This is why in 10.2.2 we introduced two new VCL panel controls. These are control containers with specific way to manage the layout and position of their child controls. You can see the controls at design time below:

(image)

TCardPanel

The CardPanel control is a set of pages, like the old PageControl, with no tabs. You display one page at a time, and it has built in support for swiping pages using a gesture. It is a collection of panels of the same size, each hosting its own controls.

At design time, you can use the local menu to add a card or select one, as shown here (image courtesy of RAD Studio DocWiki):

(image)

Each page is a "TCard" object, which is just a regular panel in disguise, so no special properties of configuration. More information at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Card_Panel_Component

TStackPanel

The stack panel is a panel with a special layout. All controls added to it are placed in a different "row" (or column if you set it horizontally). The controls can be aligned to the left, the right, the center or use the entire space (fill). You set the default alignment at the stack panel level, and you can override it for each individual control (or use the special default value to pick the parent control setting). Each of the controls hosted by the panel, gets three additional properties "injected" by the container -- at the bottom of the Object Inspector list -- as you can see below:

(image)

More information at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Stack_Panel_Component

The VCL remains a central pillar of Delphi (and C++Builder), and Embarcadero is and will continue to enhance it matching the evolution of the Windows platform and user experience, while on the other hand ensuring a very high degree of compatibility with the existing VCL code.

(image)



Debugging Delphi Apps on Android 8.1 Works

2017-12-14T11:52:01.559Z

With Android 8.1 Google has fixed an issue preventing debugging of applications on device

When Google introduced Android 8 this summer, they increased the platform security but happened to block socket access to the debugger, basically preventing debugging applications on a device. You'd see the error message "Can't open socket: Permission denied." as reported also at https://quality.embarcadero.com/browse/RSP-18992. The issue was not a change in out debugger support, but a problem at the operating system level. You can read some of the discussion here: https://github.com/android-ndk/ndk/issues/447

Now the good news is Google fixed the issue (as indicated in the thread above). We tested it on previews and it seemed fine. Now Google has shipped Android Oreo 8.1, I got it for my Nexus 5X device this morning, installed it, and I can now debug a Delphi application as usual. I captured an image of the program stopped at a breakpoint below. 

(image)

Now this is not related to 10.2.2 in any way, as the change was only on the Android side, not the RAD Studio side. What we have fixed at our end is the display of the device name as target, but that wasn't a really big issue anyway.

(image)