logo
  • Buy
  • Download
  • Documentation
  • Blog
  • Contact

Blog

30 Mar 2015

FixInsight vs RTL

by Roman Yankovsky 6 Comments

In this post I will continue to analyze Delphi source code. Last episode was about Delphi VCL, in this post we will look into Delphi RTL. I will ignore minor issues and will try to find out the most interesting pieces of code. All code examples in this post are related to Delphi XE7 (version 21.0.17017.3725).

W503 Assignment right hand side is equal to its left hand side

  constructor TNativeDownloader.Create(PublicKey: string; Salt: array of Byte; MainFile, PatchFile: TApkFileInfo);
  begin
    FMainFile := MainFile;
    FPatchFile := FPatchFile;
    FDownloader := TJNativeDownloaderLauncher.JavaClass.init(StringToJString(PublicKey), ByteArrayToJArray(Salt),
      CreateApkList(MainFile, PatchFile));
    Create;
  end;

I think, it should be “FPatchFile := PatchFile”.

W501 Empty EXCEPT block

  try
    Assert(FConnections.Count = 0); // All connections should have been removed
  except
  end;

That’s not an issue, just a WTF moment :)

W517 Variable hides a class field, method or property

procedure TTask.ExecuteReplicates(Root: TTask);
var
                                     
//  ReplicasQuitting: Boolean;
  ReplicaProc: TProc;
begin
//  ReplicasQuitting := False;
  ReplicaProc := procedure
    var
      CurrentTask, ChildTask: ITask;
    begin
      CurrentTask := CurrentTask;
      if not Root.ShouldCreateReplica {or ReplicasQuitting} then
        Exit;
      ChildTask := Root.CreateReplicaTask(ReplicaProc, Self, [TCreateFlag.Replicating, TCreateFlag.Replica]);
      ChildTask.Start;
      try
        Root.CallUserCode;
      except
        Root.HandleException(TTask(ChildTask), TObject(AcquireExceptionObject));
      end;
    end;
  ReplicaProc;
end;

W517 is a very popular warning for Delphi VCL and RTL. But I find this one to be the most interesting. TTask class has a class method called CurrentTask and CurrentTask variable hides that method. By the way there is one more warning (line 1865): “W503 Assignment right hand side is equal to its left hand side”.

So should that assignment look like “CurrentTask := Self.CurrentTask” or is it just a useless variable? In any case that code looks weird.

I cannot quote all W517 warnings, there are too many of them. But let me quote one more example from VCL.

procedure TCustomTaskDialog.ShowHelpException(E: Exception);
var
  Msg: string;
  Flags: Integer;
  SubE: Exception;
begin
  Flags := MB_OK or MB_ICONSTOP;
  if Application.UseRightToLeftReading then
    Flags := Flags or MB_RTLREADING;
  // ... [skipped]

That’s not a bug. But it could cause bugs in the future if you change this code. For instance, this code will compile even if you remove Flags variable, because TCustomTaskDialog has a property with the same name – Flags. Also it’s too easy to mistype and use the variable in this method instead of the propety and vice versa.

W504 Missing INHERITED call in destructor

destructor TJavaImport.Destroy;
begin
  TJNIResolver.DeleteGlobalRef(GetObjectID);
end;

There are a number of missed “inherited” calls again, I quote only one though.

W508 Variable is assigned twice successively

      // Another thread could start traversing the list between when we set the
      // head to P and when we assign to P.Next.  Initializing P.Next to point
      // to itself will make others spin until we assign the tail to P.Next.
      P.Next := P;
      P.Next := PThreadInfo(AtomicExchange(Pointer(FHashTable[H]), Pointer(P)));

Not an issue, as far as I understood. But I think it worth quoting. I never thought that it is possible to do multithreading like this.

That’s all I have to bring today. If you like this post, please let me know what library or framework you wish to run FixInsight against at the next time. FMX? JEDI? Anything else?


  • Markus says:
    March 30, 2015 at 9:23 pm

    Of course checking FMX with that would be interesting!

    Reply
  • Stéphane WIERZBICKI says:
    March 31, 2015 at 11:25 pm

    FMX :D

    Reply
  • Prorabdom says:
    October 24, 2023 at 7:08 am

    Здравствуйте, уважаемые читатели
    блога!

    Хочу поделиться своим впечатлением о процессе строительства частного
    дома в Москве.
    Прошлой год был для нас годом больших изменений,
    и одним из главных было решение взяться за строительство частного дома в Москве.

    ProrabDom оказались надежным и компетентным партнером
    в нашем строительном проекте.

    Профессионализм и опыт команды ProrabDom заслуживают высших похвал.

    Весь проект, начиная с первых этапов и заканчивая
    финальной сдачей дома, выполнялся
    безукоризненно и в срок.
    Дом был построен в установленные сроки, что было для нас важно.

    Кроме того, нам очень понравилась
    открытая и эффективная коммуникация с командой ProrabDom.

    Отмечу, что ProrabDom всегда были готовы учитывать наши пожелания и корректировать планы, чтобы сделать
    проект ближе к нашим ожиданиям.

    Если вы планируете строительство своего дома в Москве и ищете надежного
    партнера, ProrabDom – отличный выбор.

    Мы уверены, что ProrabDom заслуживают
    доверия, и способны воплотить в жизнь ваши мечты о собственном доме.

    Желаю успехов в вашем строительном
    проекте!

    Reply
  • Suing says:
    June 7, 2024 at 8:05 pm

    Reply
  • Heat pump says:
    July 22, 2024 at 3:40 pm

    In the heat of Goodyear, Arizona, having a reliable HVAC system is
    essential for maintaining comfort and health. William’s Air Conditioning & Heating,
    a trusted HVAC contractor, provides vital services to ensure that homes
    and businesses stay cool and comfortable. Serving neighborhoods like Amber Meadows and Estrella
    Crossroads, William’s Air Conditioning & Heating offers expert
    air conditioning repair, heating installation, and comprehensive HVAC maintenance.
    These services are crucial in Goodyear, where the
    desert climate can lead to extreme temperatures,
    making it imperative for residents to have efficient heating and
    cooling systems.

    Located in Goodyear, William’s Air Conditioning & Heating operates in a
    city founded in 1946. With a population of 105,406 as of
    2022 and 31,356 households, Goodyear is a rapidly growing community.
    The city is well-connected by I-10, a major highway that facilitates
    easy access to various parts of the city
    and beyond. An interesting fact about Goodyear is that it was named after the Goodyear Tire
    and Rubber Company, which cultivated cotton in the area to use for tire
    cords. This historical connection highlights the
    city’s industrial roots and its evolution into
    a thriving suburban community.

    HVAC repair costs in Goodyear can vary depending on the extent of the work required.
    Simple air conditioning repairs might cost a few hundred dollars, while more complex HVAC system upgrades or
    installations can range into the thousands. The city’s climate is characterized by extremely hot summers, with temperatures often exceeding
    110°F, and mild winters, with average lows in the 40s. These temperature extremes necessitate reliable HVAC systems to ensure indoor comfort and safety.
    Regular maintenance and timely repairs are essential to prevent breakdowns during
    peak usage periods, especially in the scorching summer months.

    Goodyear is home to numerous points of interest that offer a
    variety of recreational activities for residents and
    visitors. Bullard Wash Park is a beautiful green space perfect
    for picnics and outdoor activities. Estrella Mountain Regional Park offers hiking, biking, and equestrian trails set against the backdrop of stunning desert
    scenery. The Estrella Star Tower provides breathtaking views of the surrounding landscape, particularly
    at sunset. Friendship Park is a family-friendly
    destination with playgrounds and sports facilities.
    The Goodyear Community Park features a splash pad, skate park, and sports courts,
    making it a popular spot for families.

    Choosing William’s Air Conditioning & Heating for HVAC services in Goodyear is a smart
    decision for residents seeking reliable and efficient solutions.
    The company offers a comprehensive range of services, including HVAC diagnostics, energy-efficient HVAC system upgrades, and emergency HVAC service.
    With a focus on customer satisfaction and high-quality workmanship,
    William’s Air Conditioning & Heating ensures that all
    heating and cooling needs are met promptly and professionally.
    For those living in Goodyear, selecting William’s Air Conditioning & Heating
    guarantees comfort and peace of mind throughout the year.

    In Goodyear, Arizona, efficient HVAC services are a necessity due to
    the city’s harsh climate. William’s Air Conditioning & Heating stands out as a premier HVAC contractor, offering essential services to keep homes and businesses comfortable.
    Serving neighborhoods like Aldea and Coronado Village At Estrella
    Mountain Ranch, William’s Air Conditioning & Heating specializes in air conditioning
    repair, heating installation, and thorough HVAC maintenance.
    These services are vital in a city known for its extreme temperature variations, ensuring that residents can enjoy a comfortable indoor environment regardless of the weather outside.

    William’s Air Conditioning & Heating is based in Goodyear, a
    city founded in 1946 that has grown into a thriving community.
    With a population of 105,406 and 31,356 households, Goodyear is a dynamic
    city with a rich history. The city is intersected by I-10, a major highway that enhances connectivity and accessibility.

    An interesting fact about Goodyear is its rapid transformation from an agricultural
    hub, associated with the Goodyear Tire and Rubber Company, into a bustling suburban city known for its quality of life and
    recreational opportunities.

    The cost of HVAC repairs in Goodyear can range widely depending
    on the type of service required. Minor repairs
    may cost a few hundred dollars, while more extensive
    system upgrades or installations can run into the thousands.
    The city’s climate, with summer temperatures often exceeding 110°F and mild winters with average
    lows in the 40s, makes efficient HVAC systems essential.
    Regular maintenance and prompt repairs are
    necessary to ensure systems operate efficiently, particularly
    during the hottest months when demand is highest.

    Goodyear offers a variety of points of interest that cater to a wide range of preferences.

    The Estrella Mountain Regional Park is a favorite for outdoor enthusiasts, offering trails for hiking, biking, and horseback riding.

    The Estrella Star Tower provides stunning views of the desert landscape.
    Friendship Park is a popular family destination with
    playgrounds and sports fields. The Goodyear Community Park features amenities like
    a splash pad and skate park. The Wildlife World Zoo,
    Aquarium & Safari Park is an exciting destination for
    animal lovers, showcasing a wide array of wildlife and marine life.

    Opting for William’s Air Conditioning & Heating for HVAC
    services in Goodyear is a wise choice for anyone looking to
    maintain comfort and efficiency in their home or business. The company provides a full
    range of services, including HVAC diagnostics, energy-efficient upgrades, and emergency repairs.
    William’s Air Conditioning & Heating’s commitment to quality and customer
    satisfaction ensures that all heating and cooling needs are met
    with professionalism and expertise. For residents of Goodyear, choosing William’s
    Air Conditioning & Heating means enjoying reliable HVAC solutions that keep their indoor
    environment comfortable year-round.

    In the intense heat of Goodyear, Arizona, having
    a dependable HVAC system is essential. William’s Air Conditioning & Heating is a leading HVAC contractor, providing critical services to maintain comfortable living
    and working environments. Serving neighborhoods such
    as Baldridge Commons and Cottonflower, William’s Air Conditioning & Heating
    offers expert air conditioning repair, heating installation, and
    comprehensive HVAC maintenance. These services are vital in a city with
    extreme temperature fluctuations, ensuring that residents can enjoy a comfortable indoor
    climate year-round.

    Located in Goodyear, William’s Air Conditioning & Heating operates in a
    city that was founded in 1946 and has since grown into a significant urban area.
    With a population of 105,406 and 31,356 households, Goodyear is a rapidly
    expanding community. The city is well-served by I-10, a major highway that provides easy access to
    various neighborhoods and surrounding areas. One interesting fact about Goodyear is
    its historical connection to the Goodyear Tire and Rubber Company, which played
    a significant role in the city’s development by growing
    cotton for tire production.

    HVAC repair costs in Goodyear can vary significantly.
    Basic air conditioning repairs might cost a few hundred dollars, while extensive system overhauls can run into
    the thousands. The city’s climate, featuring scorching summers with temperatures often exceeding 110°F and mild
    winters with lows in the 40s, makes reliable HVAC systems indispensable.
    Regular maintenance and timely repairs are crucial
    to avoid system failures during the peak summer months.

    Goodyear boasts numerous points of interest that appeal to a wide range of visitors.

    The Bullard Wash Park is a beautiful area for outdoor activities
    and relaxation. The Estrella Mountain Regional Park offers diverse
    recreational opportunities, including hiking and biking trails.
    The Estrella Star Tower is known for its breathtaking
    views. Friendship Park is a family-friendly area with numerous amenities.

    The Goodyear Community Park is another popular spot, featuring a splash pad and various sports facilities.

    Choosing William’s Air Conditioning & Heating for HVAC services in Goodyear
    is a smart move for anyone looking to ensure comfort and efficiency.

    The company offers a comprehensive range of services, including
    HVAC diagnostics, energy-efficient system upgrades, and emergency repairs.
    William’s Air Conditioning & Heating’s dedication to quality and customer satisfaction guarantees that all heating and cooling needs are met
    promptly and professionally. For residents of Goodyear, William’s Air
    Conditioning & Heating is the best choice for reliable and effective HVAC solutions.

    For those living in the sweltering climate of Goodyear, Arizona,
    reliable HVAC services are a must. William’s Air Conditioning & Heating excels
    as a premier HVAC contractor, offering essential services
    to keep homes and businesses cool and comfortable. Serving neighborhoods
    like Bella Rosa At Canyon Trails and City Center, William’s Air Conditioning & Heating provides expert air conditioning repair, heating installation, and comprehensive HVAC maintenance.
    These services are crucial in a city known for its extreme temperatures, ensuring residents can maintain a comfortable indoor environment
    regardless of the weather.

    Based in Goodyear, William’s Air Conditioning & Heating operates in a city
    with a rich history, having been founded in 1946. Today, Goodyear is a major urban center with a
    population of 105,406 and 31,356 households. The city is traversed by I-10,
    a major highway that connects various neighborhoods and facilitates
    easy travel. An interesting fact about Goodyear is its
    evolution from a small agricultural community, named after the Goodyear
    Tire and Rubber Company, into a dynamic city known for its
    cultural diversity and rapid growth.

    The cost of HVAC repairs in Goodyear can range widely
    depending on the type of service required.
    Minor repairs may cost a few hundred dollars, while more extensive
    system upgrades or installations can run into the thousands.
    The city’s climate, with summer temperatures often exceeding 110°F and mild winters with average lows in the
    40s, makes efficient HVAC systems essential. Regular maintenance and prompt repairs are necessary
    to ensure systems operate efficiently, particularly during
    the hottest months when demand is highest.

    Reply
  • anapa-poseidon3.ru says:
    December 27, 2024 at 5:37 pm

    Nice response in return of this question with real arguments and describing all concerning that.

    Reply

Leave a Reply to Heat pump Cancel reply

Your email address will not be published. Required fields are marked *

  • Announcements
  • DelphiAST
  • DelphiSpec
  • FixInsight
  • FMX
  • Other
  • VCL

Recent Posts

  • Find leaks in Delphi with Deleaker
  • FixInsight and the inline directive
  • FixInsight 2017.04 support Delphi 10.2 Tokyo
  • FixInsight 2016.04 support Delphi 10.1 Berlin
  • FixInsight vs FMX in Delphi 10.1 Berlin

Archives

  • January 2020
  • April 2017
  • April 2016
  • March 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • April 2015
  • March 2015
  • February 2015
  • September 2014
  • August 2014
  • January 2014
  • December 2013
  • October 2013

Recent Comments

  • anapa-poseidon3.ru on FixInsight vs RTL
  • Heat pump on FixInsight vs RTL
  • Suing on FixInsight vs RTL
  • JorgeJag on Find leaks in Delphi with Deleaker
  • Prorabdom on FixInsight vs RTL
  • Home
  • Buy
  • Download
  • Documentation
  • Blog
  • Contact
  • © 2014-2015 SourceOddity|
  • Terms and Conditions|
  • Privacy Policy