× CodeTyphon MS Windows (XP, Vista, Win7, Win8.x and Win10) OS Development, discussions and problems

Question Issue with QR Code Gen

  • Robert Jenkins
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 1 week ago #16001 by Robert Jenkins
Issue with QR Code Gen was created by Robert Jenkins
I have been using the package "QRCodeGenLib4Pascal" for a while with CodeTypon and I recently upgraded to CodeTyphon Studio 7.5.  A few days after upgrading I opened up a project that had been working in CodeTyphon Studio 7.4 and got an error.  This was working on 7.4 and earlier. 


Here is a very short example which should recreate the error.


(*

Required Package "pl_QrCodeGen"  or you can get latest source
  and create your own package from github.com/Xor-el/QRCodeGenLib4Pascal
I think pl_QrCodeGen is currently using most recent code from GitHub so you don't need
to git the package.  Just use the package, "pl_QrCodeGen" which is provided with CodeTyhon.

Uses
  QlpIQrCode,
  QlpQrCode;
*)



Procedure Tform1.ButtonGoClick(Sender: TObject);
Var
  LQrCode:    IQrCode;
  LErrCorLvl: TQRCode.TEcc;
  LText:      String;
Begin
  LText := 'Hello, World!!';
  LErrCorLvl := TQrCode.TEcc.eccMedium;

  // For LErrCorLvl := Low(TQrCode.TEcc) To High(TQRCode.TEcc) Do
  Try
   //  the code below creates an "Access Violation" but it worked fine in CodeTypon Studio 7.4
    LQrCode := TQrCode.EncodeText(LText, LErrCorLvl, TEncoding.UTF8);
  Except
    On E: Exception Do
    Begin
      ShowMessage(E.Message);
    End;
  End;
End;


 

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Online
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 1 week ago #16002 by Sternas Stefanos
Replied by Sternas Stefanos on topic Issue with QR Code Gen
Thanks Sir
give us time to test and report

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Online
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 1 week ago #16003 by Sternas Stefanos
Replied by Sternas Stefanos on topic Issue with QR Code Gen
Please, test the new pl_QRCodeGen
Work OK for us with your sample code and CodeOcean QRCodeGen demo.


.

PilotLogic Architect and Core Programmer
Attachments:

Please Log in or Create an account to join the conversation.

  • Robert Jenkins
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 6 days ago #16004 by Robert Jenkins
Replied by Robert Jenkins on topic Issue with QR Code Gen
I compiled the PL QrCode sample and got the same error.

C:\codetyphon\CodeOcean\pl_QRCodeGen\samples\xbin>QrCodeGeneratorDemo.exe
Started "DoBasicDemo"
EAccessViolation: Access violation

I also copied the EXE to a second computer also running Windows 10 x64 with all the latest patches and updates applied and got the same error. Wonder if I should reinstall CodeTyphon and try again.

Any suggestions of things to try on this end?

Everything else seems to be working fine so far.

Robert

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Online
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 6 days ago - 3 months 6 days ago #16005 by Sternas Stefanos
Replied by Sternas Stefanos on topic Issue with QR Code Gen
Final Fix

The problem is in FreePascal
file: fpcsrc\compiler\x86\aoptx86.pas

function TX86AsmOptimizer.OptPass1Jcc(var p : tai) : boolean;
produce "bad" code for our case pl_QRCodeGen library.

1) Replace C:\codetyphon\fpcsrc\compiler\x86\aoptx86.pas
with the new one from 7z attach file.
OR
put the attach file in to 7z file
C:\codetyphon\allzips\src\fpc_src.7z
(fpcsrc\compiler\x86\)

2) Rebuild FPC and Typhon IDE

PilotLogic Architect and Core Programmer
Attachments:
Last edit: 3 months 6 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Robert Jenkins
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 6 days ago #16006 by Robert Jenkins
Replied by Robert Jenkins on topic Issue with QR Code Gen
I traced through the code with the debugger and eventually got to this:

Error: Project project1 raised exception class 'External: SIGSEGV'.

 In file 'source\QRCodeGen\QlpQrCode.pas' at line 709:
Result := Result + FinderPenaltyCountPatterns(LRunHistory) *

So I modified the code just to try and test some things.  Here is what I changed it to

     (* 
         if (LRunColor = 0) then
         begin
           Result := Result + FinderPenaltyCountPatterns(LRunHistory) *
             PENALTY_N3;
         end;
         *)

        if (LRunColor = 0) then
        Try
          Result := Result + FinderPenaltyCountPatterns(LRunHistory) *
          PENALTY_N3;
        Except
          ON E: Exception Do
          Begin
            System.Inc(Result);  // not sure what problems this will cause...
            E.Create(E.Message);
          End;
        End;


The code is now appears to be working with no errors.  I generated a bunch of QR Codes and had another program read them and they were correct.  Strange, I thought it would still hit and throw the exception but it never does now.  Must be something strange going on with my computer.

Robert








 

Please Log in or Create an account to join the conversation.

  • Robert Jenkins
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 6 days ago #16007 by Robert Jenkins
Replied by Robert Jenkins on topic Issue with QR Code Gen
Did as you said, replaced the file in the FPC source directory and rebuilt FPC and IDE.  Removed my modification from QR Code Gen library and now all is well.

Thank you!!!

Robert

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Online
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
3 months 6 days ago - 3 months 6 days ago #16008 by Sternas Stefanos
Replied by Sternas Stefanos on topic Issue with QR Code Gen
Thanks for your report Sir
have fun

PilotLogic Architect and Core Programmer
Last edit: 3 months 6 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.