Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. implementing tr() results in exception?
Forum Updated to NodeBB v4.3 + New Features

implementing tr() results in exception?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 615 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SPlatten
    wrote on 16 Jun 2021, 06:11 last edited by
    #1

    Today I've been through a project replacing instances of "some text" with tr("some text"), the project builds with no warnings and no errors, however when I launch in the debugger I get an exception instantly:

    Debugger encountered an exception: Exception at 0x6a432132, code: 0xc0000005: read access at 0x0, flags0x0 (first chance)
    

    Execution is halted on Q_OBJECT below:

    class SendRDF : public QMainWindow {
    Q_OBJECT
    

    No other changes have been performed.

    Kind Regards,
    Sy

    J 1 Reply Last reply 16 Jun 2021, 06:13
    0
    • S SPlatten
      16 Jun 2021, 06:15

      @jsulm , Yes, that was the first thing I tried, I'm reading through:
      https://doc.qt.io/qt-5/i18n-source-translation.html

      Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

      Q_DECLARE_TR_FUNCTIONS(SendRDF)
      

      It has a red underline, not sure if its available in Qt 5.9.2 ?

      In the class where the exception is raised there two statics initialisated:

      QString SendRDF::msstrAbort(tr("&Abort"));
      QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
      

      Could this be the cause?

      K Offline
      K Offline
      KroMignon
      wrote on 16 Jun 2021, 06:30 last edited by
      #8

      @SPlatten said in implementing tr() results in exception?:

      In the class where the exception is raised there two statics initialisated:
      Could this be the cause?

      Yes, this is probably the error source.
      This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
      You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      S 1 Reply Last reply 16 Jun 2021, 06:39
      1
      • S SPlatten
        16 Jun 2021, 06:11

        Today I've been through a project replacing instances of "some text" with tr("some text"), the project builds with no warnings and no errors, however when I launch in the debugger I get an exception instantly:

        Debugger encountered an exception: Exception at 0x6a432132, code: 0xc0000005: read access at 0x0, flags0x0 (first chance)
        

        Execution is halted on Q_OBJECT below:

        class SendRDF : public QMainWindow {
        Q_OBJECT
        

        No other changes have been performed.

        J Online
        J Online
        jsulm
        Lifetime Qt Champion
        wrote on 16 Jun 2021, 06:13 last edited by
        #2

        @SPlatten Did you try complete clean rebuild?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply 16 Jun 2021, 06:15
        1
        • J jsulm
          16 Jun 2021, 06:13

          @SPlatten Did you try complete clean rebuild?

          S Offline
          S Offline
          SPlatten
          wrote on 16 Jun 2021, 06:15 last edited by SPlatten
          #3

          @jsulm , Yes, that was the first thing I tried, I'm reading through:
          https://doc.qt.io/qt-5/i18n-source-translation.html

          Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

          Q_DECLARE_TR_FUNCTIONS(SendRDF)
          

          It has a red underline, not sure if its available in Qt 5.9.2 ?

          In the class where the exception is raised there two statics initialisated:

          QString SendRDF::msstrAbort(tr("&Abort"));
          QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
          

          Could this be the cause?

          Kind Regards,
          Sy

          J K 3 Replies Last reply 16 Jun 2021, 06:17
          0
          • S SPlatten
            16 Jun 2021, 06:15

            @jsulm , Yes, that was the first thing I tried, I'm reading through:
            https://doc.qt.io/qt-5/i18n-source-translation.html

            Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

            Q_DECLARE_TR_FUNCTIONS(SendRDF)
            

            It has a red underline, not sure if its available in Qt 5.9.2 ?

            In the class where the exception is raised there two statics initialisated:

            QString SendRDF::msstrAbort(tr("&Abort"));
            QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
            

            Could this be the cause?

            J Online
            J Online
            jsulm
            Lifetime Qt Champion
            wrote on 16 Jun 2021, 06:17 last edited by
            #4

            @SPlatten said in implementing tr() results in exception?:

            not sure if its available in Qt 5.9.2 ?

            The compiler would break with an error if the macro would not be defined.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            S 1 Reply Last reply 16 Jun 2021, 06:17
            0
            • S SPlatten
              16 Jun 2021, 06:15

              @jsulm , Yes, that was the first thing I tried, I'm reading through:
              https://doc.qt.io/qt-5/i18n-source-translation.html

              Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

              Q_DECLARE_TR_FUNCTIONS(SendRDF)
              

              It has a red underline, not sure if its available in Qt 5.9.2 ?

              In the class where the exception is raised there two statics initialisated:

              QString SendRDF::msstrAbort(tr("&Abort"));
              QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
              

              Could this be the cause?

              K Offline
              K Offline
              KroMignon
              wrote on 16 Jun 2021, 06:17 last edited by
              #5

              @SPlatten said in implementing tr() results in exception?:

              Q_DECLARE_TR_FUNCTIONS(SendRDF)

              Why do you use this?
              SendRDF::tr() should be enough.

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              S 1 Reply Last reply 16 Jun 2021, 06:19
              0
              • J jsulm
                16 Jun 2021, 06:17

                @SPlatten said in implementing tr() results in exception?:

                not sure if its available in Qt 5.9.2 ?

                The compiler would break with an error if the macro would not be defined.

                S Offline
                S Offline
                SPlatten
                wrote on 16 Jun 2021, 06:17 last edited by
                #6

                @jsulm , edited original post whilst you were posting.

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • K KroMignon
                  16 Jun 2021, 06:17

                  @SPlatten said in implementing tr() results in exception?:

                  Q_DECLARE_TR_FUNCTIONS(SendRDF)

                  Why do you use this?
                  SendRDF::tr() should be enough.

                  S Offline
                  S Offline
                  SPlatten
                  wrote on 16 Jun 2021, 06:19 last edited by
                  #7

                  @KroMignon , I don't it was something I was investigating after getting the error and reading the documentation.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • S SPlatten
                    16 Jun 2021, 06:15

                    @jsulm , Yes, that was the first thing I tried, I'm reading through:
                    https://doc.qt.io/qt-5/i18n-source-translation.html

                    Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

                    Q_DECLARE_TR_FUNCTIONS(SendRDF)
                    

                    It has a red underline, not sure if its available in Qt 5.9.2 ?

                    In the class where the exception is raised there two statics initialisated:

                    QString SendRDF::msstrAbort(tr("&Abort"));
                    QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
                    

                    Could this be the cause?

                    K Offline
                    K Offline
                    KroMignon
                    wrote on 16 Jun 2021, 06:30 last edited by
                    #8

                    @SPlatten said in implementing tr() results in exception?:

                    In the class where the exception is raised there two statics initialisated:
                    Could this be the cause?

                    Yes, this is probably the error source.
                    This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
                    You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

                    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                    S 1 Reply Last reply 16 Jun 2021, 06:39
                    1
                    • K KroMignon
                      16 Jun 2021, 06:30

                      @SPlatten said in implementing tr() results in exception?:

                      In the class where the exception is raised there two statics initialisated:
                      Could this be the cause?

                      Yes, this is probably the error source.
                      This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
                      You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

                      S Offline
                      S Offline
                      SPlatten
                      wrote on 16 Jun 2021, 06:39 last edited by
                      #9

                      @KroMignon , thank you, that makes sense.

                      Kind Regards,
                      Sy

                      1 Reply Last reply
                      0

                      9/9

                      16 Jun 2021, 06:39

                      • Login

                      • Login or register to search.
                      9 out of 9
                      • First post
                        9/9
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved