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. Qt 6.3.1 painful....
Forum Updated to NodeBB v4.3 + New Features

Qt 6.3.1 painful....

Scheduled Pinned Locked Moved Unsolved General and Desktop
31 Posts 5 Posters 4.4k Views 2 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.
  • Christian EhrlicherC Christian Ehrlicher

    Don't go from 5.12 to 6.x but from 5.12 to 5.15, remove all the deprecation warnings and then go to 6.x.
    QRegExp is deprecated since ages (a.k.a since Qt5.0)...

    SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #3

    @Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.

    Kind Regards,
    Sy

    D Christian EhrlicherC 2 Replies Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #4

      Then go with the latest Qt6. Too many changes in Qt6. Personally, I would wait a few more months to touch Qt6.

      SPlattenS 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        Then go with the latest Qt6. Too many changes in Qt6. Personally, I would wait a few more months to touch Qt6.

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #5

        @JoeCFD I don’t really have the option to wait.

        Kind regards
        Simon

        Kind Regards,
        Sy

        1 Reply Last reply
        0
        • SPlattenS SPlatten

          @Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.

          D Offline
          D Offline
          DerReisende
          wrote on last edited by
          #6

          @SPlatten you could use a virtual machine with linux and do the latest qt5 deprecation removal there. Than either move back to mac and finish the qt6 port or continue on linux until you have a running version. That should be the quickest and most painless approach IMHO.

          SPlattenS 1 Reply Last reply
          1
          • D DerReisende

            @SPlatten you could use a virtual machine with linux and do the latest qt5 deprecation removal there. Than either move back to mac and finish the qt6 port or continue on linux until you have a running version. That should be the quickest and most painless approach IMHO.

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #7

            @DerReisende , thank you, its not a race to get it finished, I just want to get the Qt 6.3.1 version building on the MacBook Pro.

            Kind Regards,
            Sy

            SPlattenS 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @DerReisende , thank you, its not a race to get it finished, I just want to get the Qt 6.3.1 version building on the MacBook Pro.

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #8

              @DerReisende , @JoeCFD , it seems Qt6 is a lot more strict on its requirements, I've fixed all the compile warnings now looking at the run-time issues that are new in this release.

              Kind Regards,
              Sy

              1 Reply Last reply
              0
              • SPlattenS SPlatten

                @Christian-Ehrlicher , I don’t think I have a choice, because the target is an Apple M1.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @SPlatten said in Qt 6.3.1 painful....:

                because the target is an Apple M1.

                So you want to tell me you can compile your program with Qt5.12 but not with Qt5.15? Nice try...

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                SPlattenS 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  @SPlatten said in Qt 6.3.1 painful....:

                  because the target is an Apple M1.

                  So you want to tell me you can compile your program with Qt5.12 but not with Qt5.15? Nice try...

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #10

                  @Christian-Ehrlicher , if I was working on my iMAC its not a problem as that's an i7, as I said I am now working on my MacBook Pro M1.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by SPlatten
                    #11

                    Still trying to fix this, in my pro file I have:

                    #-------------------------------------------------
                    #
                    # Project created by QtCreator 2018-10-15T09:17:31
                    #
                    #-------------------------------------------------
                    
                    QT += core network gui qml sql
                    greaterThan(QT_MAJOR_VERSION, 4): QT += svg widgets
                    greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat statemachine svgwidgets
                    TARGET = XMLMPAM
                    TEMPLATE = app
                    # Uncomment to include XML debug information
                    #DEFINES += DEBUG_JSON
                    DEFINES += DEBUG_LAUNCHER
                    DEFINES += DEBUG_MODULES
                    #DEFINES += DEBUG_SOCKETS
                    DEFINES += DEBUG_SCRIPT
                    DEFINES += DEBUG_SIGNALS
                    #DEFINES += DEBUG_THREADS
                    #DEFINES += DEBUG_XML
                    ####### Custom Variables
                    EXPORT_QMAKE_MAC_SDK = macosx
                    EXPORT_QMAKE_MAC_SDK_VERSION = 10.15
                    EXPORT_VALID_ARCHS = x86_64
                    # The following define makes your compiler emit warnings if you use
                    # any feature of Qt which has been marked as deprecated (the exact warnings
                    # depend on your compiler). Please consult the documentation of the
                    # deprecated API in order to know how to port your code away from it.
                    DEFINES += QT_DEPRECATED_WARNINGS
                    # Added when porting to Qt 6
                    DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
                    # You can also make your code fail to compile if you use deprecated APIs.
                    # In order to do so, uncomment the following line.
                    # You can also select to disable deprecated APIs only up to a certain version of Qt.
                    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                    CONFIG += c++11
                    CONFIG += console
                    CONFIG += sdk_no_version_check
                    CONFIG += app_bundle
                    CONFIG += QT_DEBUG_PLUGINS
                    #CONFIG += qml_debug
                    
                    SOURCES += \
                            clsCNT.cpp \
                            clsDebugService.cpp \
                            clsFileThread.cpp \
                            clsJSON.cpp \
                            clsListener.cpp \
                            clsMainWnd.cpp \
                            clsModule.cpp \
                            clsQtCheckBox.cpp \
                            clsQtComboBox.cpp \
                            clsQtFrame.cpp \
                            clsQtJsonStack.cpp \
                            clsQtLabel.cpp \
                            clsQtLayout.cpp \
                            clsQtLineEdit.cpp \
                            clsQtListWidget.cpp \
                            clsQtPushBtn.cpp \
                            clsQtRadioButton.cpp \
                            clsQtSlider.cpp \
                            clsQtTextEdit.cpp \
                            clsSignal.cpp \
                            clsScriptHelper.cpp \
                            clsThread.cpp \
                            XMLMPAM.cpp
                    
                    HEADERS += \
                            clsCNT.h \
                            clsDebugService.h \
                            clsJSON.h \
                            clsListener.h \
                            clsMainWnd.h \
                            clsFileThread.h \
                            clsModule.h \
                            clsQtCheckBox.h \
                            clsQtComboBox.h \
                            clsQtFrame.h \
                            clsQtJsonStack.h \
                            clsQtLabel.h \
                            clsQtLayout.h \
                            clsQtLineEdit.h \
                            clsQtListWidget.h \
                            clsQtPushBtn.h \
                            clsQtRadioButton.h \
                            clsQtSlider.h \
                            clsQtTextEdit.h \
                            clsScriptHelper.h \
                            clsSignal.h \
                            clsThread.h
                    
                    FORMS += \
                            clsMainWnd.ui
                    
                    # Default rules for deployment.
                    qnx: target.path = /tmp/$${TARGET}/bin
                    else: unix:!android: target.path = /opt/$${TARGET}/bin
                    !isEmpty(target.path): INSTALLS += target
                    
                    RESOURCES += \
                        clsmainwnd.qrc
                    
                    DISTFILES += \
                        config/form.xml \
                        config/form2.xml \
                        config/simon.js \
                        config/simon.xml \
                        config/simon2.js \
                        config/xmlmpam.xml
                    

                    Just spotted:

                    EXPORT_QMAKE_MAC_SDK = macosx
                    EXPORT_QMAKE_MAC_SDK_VERSION = 10.15
                    EXPORT_VALID_ARCHS = x86_64
                    

                    Could these be a problem on the MacBook Pro M1 ?

                    Have modified pro file for apple M1 build:

                    EXPORT_VALID_ARCHS = arm64
                    

                    Building now...how can I add a conditional argument to build for either x86_64 on iMAC or arm64 on macBook Pro M1 ?

                    Kind Regards,
                    Sy

                    SPlattenS 1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      Still trying to fix this, in my pro file I have:

                      #-------------------------------------------------
                      #
                      # Project created by QtCreator 2018-10-15T09:17:31
                      #
                      #-------------------------------------------------
                      
                      QT += core network gui qml sql
                      greaterThan(QT_MAJOR_VERSION, 4): QT += svg widgets
                      greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat statemachine svgwidgets
                      TARGET = XMLMPAM
                      TEMPLATE = app
                      # Uncomment to include XML debug information
                      #DEFINES += DEBUG_JSON
                      DEFINES += DEBUG_LAUNCHER
                      DEFINES += DEBUG_MODULES
                      #DEFINES += DEBUG_SOCKETS
                      DEFINES += DEBUG_SCRIPT
                      DEFINES += DEBUG_SIGNALS
                      #DEFINES += DEBUG_THREADS
                      #DEFINES += DEBUG_XML
                      ####### Custom Variables
                      EXPORT_QMAKE_MAC_SDK = macosx
                      EXPORT_QMAKE_MAC_SDK_VERSION = 10.15
                      EXPORT_VALID_ARCHS = x86_64
                      # The following define makes your compiler emit warnings if you use
                      # any feature of Qt which has been marked as deprecated (the exact warnings
                      # depend on your compiler). Please consult the documentation of the
                      # deprecated API in order to know how to port your code away from it.
                      DEFINES += QT_DEPRECATED_WARNINGS
                      # Added when porting to Qt 6
                      DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
                      # You can also make your code fail to compile if you use deprecated APIs.
                      # In order to do so, uncomment the following line.
                      # You can also select to disable deprecated APIs only up to a certain version of Qt.
                      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                      CONFIG += c++11
                      CONFIG += console
                      CONFIG += sdk_no_version_check
                      CONFIG += app_bundle
                      CONFIG += QT_DEBUG_PLUGINS
                      #CONFIG += qml_debug
                      
                      SOURCES += \
                              clsCNT.cpp \
                              clsDebugService.cpp \
                              clsFileThread.cpp \
                              clsJSON.cpp \
                              clsListener.cpp \
                              clsMainWnd.cpp \
                              clsModule.cpp \
                              clsQtCheckBox.cpp \
                              clsQtComboBox.cpp \
                              clsQtFrame.cpp \
                              clsQtJsonStack.cpp \
                              clsQtLabel.cpp \
                              clsQtLayout.cpp \
                              clsQtLineEdit.cpp \
                              clsQtListWidget.cpp \
                              clsQtPushBtn.cpp \
                              clsQtRadioButton.cpp \
                              clsQtSlider.cpp \
                              clsQtTextEdit.cpp \
                              clsSignal.cpp \
                              clsScriptHelper.cpp \
                              clsThread.cpp \
                              XMLMPAM.cpp
                      
                      HEADERS += \
                              clsCNT.h \
                              clsDebugService.h \
                              clsJSON.h \
                              clsListener.h \
                              clsMainWnd.h \
                              clsFileThread.h \
                              clsModule.h \
                              clsQtCheckBox.h \
                              clsQtComboBox.h \
                              clsQtFrame.h \
                              clsQtJsonStack.h \
                              clsQtLabel.h \
                              clsQtLayout.h \
                              clsQtLineEdit.h \
                              clsQtListWidget.h \
                              clsQtPushBtn.h \
                              clsQtRadioButton.h \
                              clsQtSlider.h \
                              clsQtTextEdit.h \
                              clsScriptHelper.h \
                              clsSignal.h \
                              clsThread.h
                      
                      FORMS += \
                              clsMainWnd.ui
                      
                      # Default rules for deployment.
                      qnx: target.path = /tmp/$${TARGET}/bin
                      else: unix:!android: target.path = /opt/$${TARGET}/bin
                      !isEmpty(target.path): INSTALLS += target
                      
                      RESOURCES += \
                          clsmainwnd.qrc
                      
                      DISTFILES += \
                          config/form.xml \
                          config/form2.xml \
                          config/simon.js \
                          config/simon.xml \
                          config/simon2.js \
                          config/xmlmpam.xml
                      

                      Just spotted:

                      EXPORT_QMAKE_MAC_SDK = macosx
                      EXPORT_QMAKE_MAC_SDK_VERSION = 10.15
                      EXPORT_VALID_ARCHS = x86_64
                      

                      Could these be a problem on the MacBook Pro M1 ?

                      Have modified pro file for apple M1 build:

                      EXPORT_VALID_ARCHS = arm64
                      

                      Building now...how can I add a conditional argument to build for either x86_64 on iMAC or arm64 on macBook Pro M1 ?

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by SPlatten
                      #12

                      @SPlatten , I'm struggling to understand by the application crashes on start-up when run on the MacBook Pro m1, it doesn't on the iMAC.

                      Its very difficult to debug because it halts in qarraydata on line 178 but the debug locals area only contains:

                      [statics]
                          None
                      allocSize.   <not accessible>
                      header.       0x0
                      

                      Can anyone suggest how I might fault find this problem?

                      There is a problem report but its two large to post.

                      Kind Regards,
                      Sy

                      D 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @SPlatten , I'm struggling to understand by the application crashes on start-up when run on the MacBook Pro m1, it doesn't on the iMAC.

                        Its very difficult to debug because it halts in qarraydata on line 178 but the debug locals area only contains:

                        [statics]
                            None
                        allocSize.   <not accessible>
                        header.       0x0
                        

                        Can anyone suggest how I might fault find this problem?

                        There is a problem report but its two large to post.

                        D Offline
                        D Offline
                        DerReisende
                        wrote on last edited by
                        #13

                        @SPlatten In another thread here I mentioned architectural differences of Apple Silicon to intel which may cause working intel code to crash when compiled for Apple Silicon. Apple suggests in this video to use thread sanitizer etc to hunt for those bugs in your code. If your x86 app runs without problems using Rosetta but crashes when compiled as apple native then you may have one of the problems described in the video. It might worth a shot compiling and running your app with various sanitizer options.

                        SPlattenS 1 Reply Last reply
                        0
                        • D DerReisende

                          @SPlatten In another thread here I mentioned architectural differences of Apple Silicon to intel which may cause working intel code to crash when compiled for Apple Silicon. Apple suggests in this video to use thread sanitizer etc to hunt for those bugs in your code. If your x86 app runs without problems using Rosetta but crashes when compiled as apple native then you may have one of the problems described in the video. It might worth a shot compiling and running your app with various sanitizer options.

                          SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #14

                          @DerReisende , thank you, I will go take a look.

                          Kind Regards,
                          Sy

                          D 1 Reply Last reply
                          0
                          • SPlattenS SPlatten

                            @DerReisende , thank you, I will go take a look.

                            D Offline
                            D Offline
                            DerReisende
                            wrote on last edited by
                            #15

                            @SPlatten And for Apple SIlicon builds the minimum sdk should be 11.0. That was the one when it got introduced and Apple uses -target arm64-apple-macos11 in their samples here.

                            SPlattenS 1 Reply Last reply
                            0
                            • D DerReisende

                              @SPlatten And for Apple SIlicon builds the minimum sdk should be 11.0. That was the one when it got introduced and Apple uses -target arm64-apple-macos11 in their samples here.

                              SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by SPlatten
                              #16

                              @DerReisende , how or where do I get the version to assign to EXPORT_QMAKE_MAC_SDK_VERSION ?
                              [Edit] Is this the version displayed when running Xcode ? In my case 13.4.1
                              [Edit2] My project still crashes in qarraydata on line 178, `I'm wondering if there is an issue with the type long long as Qt Creator does not show the value associated with allocSize which is of type long long ?

                              Kind Regards,
                              Sy

                              D 1 Reply Last reply
                              0
                              • SPlattenS SPlatten

                                @DerReisende , how or where do I get the version to assign to EXPORT_QMAKE_MAC_SDK_VERSION ?
                                [Edit] Is this the version displayed when running Xcode ? In my case 13.4.1
                                [Edit2] My project still crashes in qarraydata on line 178, `I'm wondering if there is an issue with the type long long as Qt Creator does not show the value associated with allocSize which is of type long long ?

                                D Offline
                                D Offline
                                DerReisende
                                wrote on last edited by
                                #17

                                @SPlatten I am not sure if QMAKE_MAC_SDK_VERSION is the correct way to set the macos minimum sdk version during compilation. But I have to admit that I dont use qmake. A quick search gave me this thread which may be more correct to specify the target sdk for compilation.

                                Did you compile and run the project with -fsanitize=thread compiler option`?

                                SPlattenS 1 Reply Last reply
                                0
                                • D DerReisende

                                  @SPlatten I am not sure if QMAKE_MAC_SDK_VERSION is the correct way to set the macos minimum sdk version during compilation. But I have to admit that I dont use qmake. A quick search gave me this thread which may be more correct to specify the target sdk for compilation.

                                  Did you compile and run the project with -fsanitize=thread compiler option`?

                                  SPlattenS Offline
                                  SPlattenS Offline
                                  SPlatten
                                  wrote on last edited by
                                  #18

                                  @DerReisende Thank you, I want to keep using the .pro file if possible so I will look for a MIN version of the directive.

                                  Kind Regards,
                                  Sy

                                  1 Reply Last reply
                                  0
                                  • SPlattenS Offline
                                    SPlattenS Offline
                                    SPlatten
                                    wrote on last edited by SPlatten
                                    #19

                                    I'm not sure I am winning this battle Qt 6.3.1 on my MacBook Pro Apple M1 is not going anywhere fast.

                                    My application is multi-threaded, when I run the application it is halting in (__pthread_kill) showing a window containing nothing but hex, the stack trade showing in Test Results panel contains:

                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                        
                                    1  __pthread_kill                                                                                                               (arm64e) /usr/lib/system/libsystem_kernel.dylib                                         0x185b2ed98 
                                    2  pthread_kill                                                                                                                 (arm64e) /usr/lib/system/libsystem_pthread.dylib                                        0x185b63ee0 
                                    3  abort                                                                                                                        (arm64e) /usr/lib/system/libsystem_c.dylib                                              0x185a9e340 
                                    4  malloc_vreport                                                                                                               (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x1859808c0 
                                    5  malloc_zone_error                                                                                                            (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x185995c84 
                                    6  nanov2_allocate_from_block                                                                                                   (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x185972bc4 
                                    7  nanov2_allocate                                                                                                              (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x1859721e0 
                                    8  nanov2_calloc                                                                                                                (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x18597437c 
                                    9  _malloc_zone_calloc                                                                                                          (arm64e) /usr/lib/system/libsystem_malloc.dylib                                         0x18598f840 
                                    10 class_createInstance                                                                                                         (arm64e) /usr/lib/libobjc.A.dylib                                                       0x1859ea404 
                                    11 _os_object_alloc_realized                                                                                                    (arm64e) /usr/lib/system/libdispatch.dylib                                              0x18599f568 
                                    12 _xpc_dictionary_deserialize                                                                                                  (arm64e) /usr/lib/system/libxpc.dylib                                                   0x1858982d0 
                                    13 _xpc_array_deserialize                                                                                                       (arm64e) /usr/lib/system/libxpc.dylib                                                   0x1858981ec 
                                    14 _xpc_dictionary_unpack_value                                                                                                 (arm64e) /usr/lib/system/libxpc.dylib                                                   0x185893fc0 
                                    15 _xpc_dictionary_unpack_value_and_vend                                                                                        (arm64e) /usr/lib/system/libxpc.dylib                                                   0x185895424 
                                    16 _xpc_dictionary_look_up                                                                                                      (arm64e) /usr/lib/system/libxpc.dylib                                                   0x18588fe8c 
                                    17 -[CFPrefsSearchListSource handleReply:toRequestNewDataMessage:onConnection:retryCount:error:]                                (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation  0x185be46a4 
                                    18 __80-[CFPrefsSearchListSource alreadylocked_generationCountFromListOfSources:count:]_block_invoke                            (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation  0x185be45a8 
                                    19 __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke_2 (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation  0x185be4540 
                                    20 -[_CFXPreferences withConnectionForRole:performBlock:]                                                                       (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation  0x185be4100 
                                    21 __104-[CFPrefsSearchListSource synchronouslySendDaemonMessage:andAgentMessage:andDirectMessage:replyHandler:]_block_invoke   (arm64e) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation  0x185be40a4 
                                    22 _dispatch_client_callout2                                                                                                    (arm64e) /usr/lib/system/libdispatch.dylib                                              0x1859a01f4 
                                    23 _dispatch_apply_invoke                                                                                                       (arm64e) /usr/lib/system/libdispatch.dylib                                              0x1859b3954 
                                    24 _dispatch_client_callout                                                                                                     (arm64e) /usr/lib/system/libdispatch.dylib                                              0x1859a01b4 
                                    25 _dispatch_root_queue_drain                                                                                                   (arm64e) /usr/lib/system/libdispatch.dylib                                              0x1859b1a04 
                                    26 _dispatch_worker_thread2                                                                                                     (arm64e) /usr/lib/system/libdispatch.dylib                                              0x1859b2104 
                                    27 _pthread_wqthread                                                                                                            (arm64e) /usr/lib/system/libsystem_pthread.dylib                                        0x185b60324 
                                    
                                    

                                    Kind Regards,
                                    Sy

                                    1 Reply Last reply
                                    0
                                    • JoeCFDJ Offline
                                      JoeCFDJ Offline
                                      JoeCFD
                                      wrote on last edited by
                                      #20

                                      I guess you are able to use c++20 now. Adding logging code into your threads may enable you to find issues more quickly.
                                      https://mariusbancila.ro/blog/2021/07/03/writing-a-simple-logging-function-in-c20/

                                      D 1 Reply Last reply
                                      0
                                      • JoeCFDJ JoeCFD

                                        I guess you are able to use c++20 now. Adding logging code into your threads may enable you to find issues more quickly.
                                        https://mariusbancila.ro/blog/2021/07/03/writing-a-simple-logging-function-in-c20/

                                        D Offline
                                        D Offline
                                        DerReisende
                                        wrote on last edited by
                                        #21

                                        @JoeCFD You don't need c++20 to do that, QMessageLogContext does give you the same information if you install a proper message handler:

                                        static void qt_message_handler(QtMsgType type, [[maybe_unused]] const QMessageLogContext &context, const QString &msg) {
                                            const QByteArray localMsg = msg.toLocal8Bit();
                                        #ifdef NDEBUG
                                            const auto out_msg = fmt::format("\t{}", localMsg.constData());
                                        #else
                                            const char *function = context.function ? context.function : "";
                                            const auto out_msg = fmt::format("\t{} [LINE:{}, {}]",
                                                                              localMsg.constData(),
                                                                              context.line,
                                                                              function);
                                        #endif
                                            switch (type) {
                                                case QtDebugMsg:
                                                    spdlog::debug(out_msg);
                                                    break;
                                                case QtInfoMsg:
                                                    spdlog::info(out_msg);
                                                    break;
                                                case QtWarningMsg:
                                                    spdlog::warn(out_msg);
                                                    break;
                                                case QtCriticalMsg:
                                                    spdlog::error(out_msg);
                                                    break;
                                                case QtFatalMsg:
                                                    spdlog::critical(out_msg);
                                                    spdlog::shutdown();
                                                    break;
                                            }
                                        }
                                        
                                        void init_logging() {
                                            init_spdlog();
                                        
                                            qInstallMessageHandler(qt_message_handler);
                                        } 
                                        

                                        I am using spdlog and fmt::format for logging and formatting but in the end you will get almost the same details for all Qt logging calls as with your example.

                                        SPlattenS JoeCFDJ 2 Replies Last reply
                                        0
                                        • D DerReisende

                                          @JoeCFD You don't need c++20 to do that, QMessageLogContext does give you the same information if you install a proper message handler:

                                          static void qt_message_handler(QtMsgType type, [[maybe_unused]] const QMessageLogContext &context, const QString &msg) {
                                              const QByteArray localMsg = msg.toLocal8Bit();
                                          #ifdef NDEBUG
                                              const auto out_msg = fmt::format("\t{}", localMsg.constData());
                                          #else
                                              const char *function = context.function ? context.function : "";
                                              const auto out_msg = fmt::format("\t{} [LINE:{}, {}]",
                                                                                localMsg.constData(),
                                                                                context.line,
                                                                                function);
                                          #endif
                                              switch (type) {
                                                  case QtDebugMsg:
                                                      spdlog::debug(out_msg);
                                                      break;
                                                  case QtInfoMsg:
                                                      spdlog::info(out_msg);
                                                      break;
                                                  case QtWarningMsg:
                                                      spdlog::warn(out_msg);
                                                      break;
                                                  case QtCriticalMsg:
                                                      spdlog::error(out_msg);
                                                      break;
                                                  case QtFatalMsg:
                                                      spdlog::critical(out_msg);
                                                      spdlog::shutdown();
                                                      break;
                                              }
                                          }
                                          
                                          void init_logging() {
                                              init_spdlog();
                                          
                                              qInstallMessageHandler(qt_message_handler);
                                          } 
                                          

                                          I am using spdlog and fmt::format for logging and formatting but in the end you will get almost the same details for all Qt logging calls as with your example.

                                          SPlattenS Offline
                                          SPlattenS Offline
                                          SPlatten
                                          wrote on last edited by SPlatten
                                          #22

                                          @DerReisende , thank you, I've done this already for several years, here is the output to my log file:

                                          XMLMPAM start-up
                                          Listening to any local IP address on port: 8123
                                          S000000000003E000000000374T09:56:43.345T:DL00004842P../clsMainWnd.cpp[void clsXMLnode::update]
                                          "Node:label ID:lbl1 X:12 Y:261 W:100 H:30 Text:<a href=\"http://google.com\" style=\"color:#000000;text-decoration:none;\">Google</a>:"
                                          S000000000004E000000000407T09:56:43.378T:DL00003985P../clsMainWnd.cpp[static clsXMLnode *clsXMLnode::spobjParse]
                                          "label"
                                          S000000000005E000000000408T09:56:43.379T:DL00004842P../clsMainWnd.cpp[void clsXMLnode::update]
                                          "Node:label ID:lbl1 X:12 Y:261 W:100 H:30 Text:<a href=\"http://google.com\" style=\"color:#000000;text-decoration:none;\">Google</a>:"
                                          S000000000006E000000000408T09:56:43.379T:D:"Node:label ID:lbl1 X:12 Y:261 W:100 H:30 Text:<a href=\"http://google.com\" style=\"color:#000000;text-decoration:none;\">Google</a>:"
                                          S000000000007E000000007037T09:56:50.008T:DL00000798P../clsMainWnd.cpp[clsXMLnode::clsXMLnode]
                                          "test99"
                                          S000000000008E000000007037T09:56:50.008T:DL00003985P../clsMainWnd.cpp[static clsXMLnode *clsXMLnode::spobjParse]
                                          "label"
                                          S000000000009E000000007104T09:56:50.075T:D:"label"
                                          S000000000010E000000007113T09:56:50.084T:D:"label"
                                          S000000000011E000000007128T09:56:50.099T:D:"label"
                                          Process:  Arg[0]: 8123
                                          Process:  Arg[1]: 8124
                                          Process:  Arg[2]: 24150
                                          Process:  Arg[3]: f1
                                          Process is NOT running, launching
                                          S000000000014E000000007171T09:56:50.142T:DL00000553P../clsModule.cpp[void clsModule::setProgram]
                                          Starting: f1:mdFIO
                                          Registering decoder for file simon.js, function: blnDecodeFIOcmd
                                          Process:  Arg[0]: 8123
                                          Process:  Arg[1]: 8125
                                          Process:  Arg[2]: 24150
                                          Process:  Arg[3]: s1
                                          Process is NOT running, launching
                                          S000000000018E000000007177T09:56:50.148T:D:Starting: s1:mdSQL
                                          Registering decoder for file simon.js, function: blnDecodeSQLcmd
                                          Process:  Arg[0]: 8123
                                          Process:  Arg[1]: 8126
                                          Process:  Arg[2]: 24150
                                          Process:  Arg[3]: x1
                                          Process is NOT running, launching
                                          S000000000022E000000007182T09:56:50.153T:D:Starting: x1:mdXML
                                          Registering decoder for file simon.js, function: blnDecodeXMLcmd
                                          S000000000024E000000007234T09:56:50.205T:DL00000571P../clsModule.cpp[auto clsModule::setProgram]
                                          PID for mdXML: 24171, On port: 8123
                                          Process:  mdXML started
                                          S000000000026E000000007234T09:56:50.205T:D:PID for mdFIO: 24165, On port: 8123
                                          Process:  mdFIO started
                                          S000000000028E000000007234T09:56:50.205T:D:PID for mdSQL: 24168, On port: 8123
                                          Process:  mdSQL started
                                          Client connecting...
                                          Client connecting...
                                          Client connecting...
                                          Client connected
                                          Client connected
                                          Client connected
                                          !s1!Client connecting...
                                          !s1!Client connected
                                          !f1!Client connecting...
                                          !f1!Client connected
                                          !x1!Client connecting...
                                          !x1!Client connected
                                          !f1!S000000000042E000000000131T09:56:50.347DL00000731F../mdFIO/clsModFIO.cpp[void clsModFIO::doComm
                                          !f1!S000000000042E000000000131T09:56:50.347DL00000731F../mdFIO/clsModFIO.cpp[void clsModFIO::doCommand]
                                          2022-08-17 08:56:50,  Command#1: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000043E000000000131T09:56:50.347D:Length
                                          !f1!S000000000043E000000000131T09:56:50.347D:Length: 1
                                          !f1!S000000000044E000000000131T09:56:50.347D:2022-08
                                          !f1!S000000000044E000000000131T09:56:50.347D:2022-08-17 08:56:50,  Command#2: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000045E000000000131T09:56:50.347D:Length
                                          !f1!S000000000045E000000000131T09:56:50.347D:Length: 2
                                          !f1!S000000000046E000000000131T09:56:50.347D:2022-08
                                          !f1!S000000000046E000000000131T09:56:50.347D:2022-08-17 08:56:50,  Command#3: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000047E000000000131T09:56:50.347D:Length
                                          !f1!S000000000047E000000000131T09:56:50.347D:Length: 4
                                          !f1!S000000000048E000000000131T09:56:50.348D:2022-08
                                          !f1!S000000000048E000000000131T09:56:50.348D:2022-08-17 08:56:50,  Command#4: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000049E000000000131T09:56:50.348D:Length
                                          !f1!S000000000049E000000000131T09:56:50.348D:Length: 8
                                          !f1!S000000000050E000000000131T09:56:50.348D:2022-08
                                          !f1!S000000000050E000000000131T09:56:50.348D:2022-08-17 08:56:50,  Command#5: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000051E000000000131T09:56:50.348D:Length
                                          !f1!S000000000051E000000000131T09:56:50.348D:Length: 4
                                          !f1!S000000000052E000000000131T09:56:50.348D:2022-08
                                          !f1!S000000000052E000000000131T09:56:50.348D:2022-08-17 08:56:50,  Command#6: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000053E000000000131T09:56:50.348D:Length
                                          !f1!S000000000053E000000000131T09:56:50.348D:Length: 8
                                          !f1!S000000000054E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000054E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#7: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000055E000000000132T09:56:50.348D:Length
                                          !f1!S000000000055E000000000132T09:56:50.348D:Length: 27
                                          !f1!S000000000056E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000056E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#8: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000057E000000000132T09:56:50.348D:Length
                                          !f1!S000000000057E000000000132T09:56:50.348D:Length: 1
                                          !f1!S000000000058E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000058E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#9: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000059E000000000132T09:56:50.348D:Length
                                          !f1!S000000000059E000000000132T09:56:50.348D:Length: 2
                                          !f1!S000000000060E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000060E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#10: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000061E000000000132T09:56:50.348D:Length
                                          !f1!S000000000061E000000000132T09:56:50.348D:Length: 4
                                          !f1!S000000000062E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000062E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#11: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rb
                                          !f1!S000000000063E000000000132T09:56:50.348D:Length
                                          !f1!S000000000063E000000000132T09:56:50.348D:Length: 8
                                          !f1!S000000000064E000000000132T09:56:50.348D:2022-08
                                          !f1!S000000000064E000000000132T09:56:50.348D:2022-08-17 08:56:50,  Command#12: find, File: /Users/sy/XMLMPAM/config/test.dat, Mode: r
                                          !f1!S000000000065E000000000132T09:56:50.348D:Length
                                          !f1!S000000000065E000000000132T09:56:50.348D:Length: 18446744073709551615
                                          !f1!S000000000066E000000000132T09:56:50.349D:2022-08
                                          !f1!S000000000066E000000000132T09:56:50.349D:2022-08-17 08:56:50,  Command#13: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rt
                                          !f1!S000000000067E000000000132T09:56:50.349D:Length
                                          !f1!S000000000067E000000000132T09:56:50.349D:Length: 3
                                          !f1!S000000000068E000000000132T09:56:50.349D:2022-08
                                          !f1!S000000000068E000000000132T09:56:50.349D:2022-08-17 08:56:50,  Command#14: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rt
                                          !f1!S000000000069E000000000132T09:56:50.349D:Length
                                          !f1!S000000000069E000000000132T09:56:50.349D:Length: 4
                                          !f1!S000000000070E000000000132T09:56:50.349D:2022-08
                                          !f1!S000000000070E000000000132T09:56:50.349D:2022-08-17 08:56:50,  Command#15: read, File: /Users/sy/XMLMPAM/config/test.dat, Mode: rt
                                          !f1!S000000000071E000000000132T09:56:50.349D:Positio
                                          !f1!S000000000071E000000000132T09:56:50.349D:Position: -15
                                          !f1!S000000000072E000000000133T09:56:50.349D:Length
                                          !f1!S000000000072E000000000133T09:56:50.349D:Length: 5
                                          !f1!S000000000073E000000000133T09:56:50.349D:2022-08
                                          !f1!S000000000073E000000000133T09:56:50.349D:2022-08-17 08:56:50,  Command#16: tell, File: /Users/sy/XMLMPAM/config/test.dat, Mode: r
                                          !f1!S000000000074E000000000133T09:56:50.349D:Length
                                          !f1!S000000000074E000000000133T09:56:50.349D:Length: 18446744073709551615
                                          !s1!S000000000008E000000000137T09:56:50.343DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000008E000000000137T09:56:50.343DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"connect","params":{"database":"test","driver":"QMYSQL","host":"localhost","pass":"resuocra","usr":"root"}}
                                          !s1!S000000000009E000000000179T09:56:50.384DL00000212F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000009E000000000179T09:56:50.384DL00000212F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"connect","output":"connected"}
                                          S000000000036E000000007753T09:56:50.724T:W:QObject: Cannot create children for a parent that is in a different thread.
                                          (Parent is QNativeSocketEngine(0x600000012910), parent's thread is clsServer(0x600000257fc0), current thread is clsThread(0x600002c2a000)
                                          !s1!S000000000010E000000000519T09:56:50.724DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000010E000000000519T09:56:50.724DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm LIMIT ?;"}
                                          !s1!S000000000011E000000000521T09:56:50.726DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000011E000000000521T09:56:50.726DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected","records":[{"intEmployed":"1","intPri":"1","vcAddress":"Latona House\nStation Road\nCantley\nNorfolk\nNR13 3SQ","vcFirstName":"Simon","vcSex":"Male","vcSurName":"Platten"},{"intEmployed":"1","intPri":"2","vcAddress":"Latona House\nStation Road\nCantley\nNorfolk\nNR13 3SQ","vcFirstName":"Susan","vcSex":"Female","vcSurName":"Platten"}]}
                                          !s1!S000000000012E000000000781T09:56:50.987DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000012E000000000781T09:56:50.987DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm WHERE intPri NOT IN(1,2) LIMIT ?;"}
                                          !s1!S000000000013E000000000782T09:56:50.987DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000013E000000000782T09:56:50.987DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected"}
                                          !s1!S000000000014E000000001044T09:56:51.249DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000014E000000001044T09:56:51.249DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm WHERE intPri NOT IN(1,2) LIMIT ?;"}
                                          !s1!S000000000015E000000001044T09:56:51.249DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000015E000000001044T09:56:51.249DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected"}
                                          !s1!S000000000016E000000001304T09:56:51.510DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000016E000000001304T09:56:51.510DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm WHERE intPri NOT IN(1,2) LIMIT ?;"}
                                          !s1!S000000000017E000000001305T09:56:51.510DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000017E000000001305T09:56:51.510DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected"}
                                          !s1!S000000000018E000000001562T09:56:51.767DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000018E000000001562T09:56:51.767DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm WHERE intPri NOT IN(1,2) LIMIT ?;"}
                                          !s1!S000000000019E000000001562T09:56:51.768DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000019E000000001562T09:56:51.768DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected"}
                                          !s1!S000000000020E000000001812T09:56:52.017DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000020E000000001812T09:56:52.017DL00000171F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"addrTo":"s1","args":[2],"command":"query","handler":"simon2.js@testFormHandler","msgType":"notify","source":"XMLMPAM","sql":"SELECT * FROM test.tblForm WHERE intPri NOT IN(1,2) LIMIT ?;"}
                                          !s1!S000000000021E000000001812T09:56:52.017DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoC
                                          !s1!S000000000021E000000001812T09:56:52.017DL00000276F../mdSQL/clsModSQL.cpp[bool clsModSQL::blnDoCmd]
                                          {"command":"query","handler":"simon2.js@testFormHandler","output":"connected"}
                                          S000000000037E000000009157T09:56:52.128T:W:QObject: Cannot create children for a parent that is in a different thread.
                                          (Parent is QNativeSocketEngine(0x600000025290), parent's thread is clsServer(0x600000255400), current thread is clsThread(0x600002c2a000)
                                          S000000000038E000000009158T09:56:52.129T:W:QObject: Cannot create children for a parent that is in a different thread.
                                          (Parent is QNativeSocketEngine(0x6000000196e0), parent's thread is clsServer(0x600000256f60), current thread is clsThread(0x600002c2a000)
                                          

                                          Where:
                                          S is the sequence number
                                          E is the elapsed time
                                          T is the time stamp
                                          T:C Type:Critical warning
                                          T:D Type:Debug message
                                          T:F Type:Fatal error
                                          T:W Type:Warning
                                          L is the line number
                                          P is the path and file name

                                          This is what is shown in the Application Output which suggests the issue is generated during the initialisation of QApplication.

                                          
                                          10:04:03: Debugging /Users/sy/XMLMPAM/build-XMLMPAM-Desktop_Qt_5_15_2_clang_64bit-Debug/XMLMPAM.app/Contents/MacOS/XMLMPAM ~/XMLMPAM/config/xmlmpam ...
                                          
                                          got fallback qt version 0x50f02
                                          2022-08-17 10:04:08.921420+0100 XMLMPAM[24714:211122] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=24714
                                          2022-08-17 10:04:08.921503+0100 XMLMPAM[24714:211122] SecTaskCopyDebugDescription: XMLMPAM[24714]/0#-1 LF=0
                                          2022-08-17 10:04:09.414338+0100 XMLMPAM[24714:211122] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=24714
                                          2022-08-17 10:04:09.414418+0100 XMLMPAM[24714:211122] SecTaskCopyDebugDescription: XMLMPAM[24714]/0#-1 LF=0
                                          

                                          Found this:
                                          https://apple.stackexchange.com/questions/237465/what-means-sectaskloadentlitlements-failed-error-22

                                          Kind Regards,
                                          Sy

                                          D 1 Reply Last reply
                                          0

                                          • Login

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