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. How to avoid repeated execution of loading Qlibrary?
Forum Updated to NodeBB v4.3 + New Features

How to avoid repeated execution of loading Qlibrary?

Scheduled Pinned Locked Moved Unsolved General and Desktop
23 Posts 5 Posters 1.6k 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.
  • R Offline
    R Offline
    RogerBreton
    wrote on 29 Apr 2021, 17:37 last edited by
    #14

    I wanted to try the changes in debug mode but I immediately ran into the following error message :

    Error.jpg

    Time for a cup of coffee...

    Roger Breton
    www.graxx.ca

    J 1 Reply Last reply 29 Apr 2021, 17:49
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 29 Apr 2021, 17:44 last edited by
      #15

      @RogerBreton said in How to avoid repeated execution of loading Qlibrary?:

      Time for a cup of coffee...

      I would rather say - time for a debugging session :)

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

      1 Reply Last reply
      1
      • R RogerBreton
        29 Apr 2021, 17:37

        I wanted to try the changes in debug mode but I immediately ran into the following error message :

        Error.jpg

        Time for a cup of coffee...

        J Offline
        J Offline
        JonB
        wrote on 29 Apr 2021, 17:49 last edited by JonB
        #16

        @RogerBreton
        If, from what you have shown, you presently have:

           bool Result;
            Result = myLib.load();
        RB_StartMeasurement = reinterpret_cast<Fn6>(myLib.resolve("FDX_StartMeasurement"));
        sdkError = RB_StartMeasurement();
        

        without checking the intermediate return result variables, RB_StartMeasurement may be nullptr. Then RB_StartMeasurement() would cause a SIGSEGV?

        R 1 Reply Last reply 29 Apr 2021, 18:17
        1
        • J JonB
          29 Apr 2021, 17:49

          @RogerBreton
          If, from what you have shown, you presently have:

             bool Result;
              Result = myLib.load();
          RB_StartMeasurement = reinterpret_cast<Fn6>(myLib.resolve("FDX_StartMeasurement"));
          sdkError = RB_StartMeasurement();
          

          without checking the intermediate return result variables, RB_StartMeasurement may be nullptr. Then RB_StartMeasurement() would cause a SIGSEGV?

          R Offline
          R Offline
          RogerBreton
          wrote on 29 Apr 2021, 18:17 last edited by
          #17

          @JonB I don't dare say RB_StartMeasurement may be a nullptr in ALL LIKELIHOOD, and that maybe the cause of the segmentation fault. That is exactly my hypothesis. So, if that is the case, this proves my intuition : where is the application getting the DLL from? If its name isn't specified anywhere? It is not in the PRO file.

          I was thinking, perhaps, I should test whether the library is loaded before calling RB_StartMeasurement? And if it is not loaded, then load it? But that would not explain why I get the SIGSEV when the application tries to load? Or is it happening in the constructor?

          Somehow, I must be missing some important piece of the puzzle -- I'll continue to look around but I am optimistic...

          Roger Breton
          www.graxx.ca

          J 1 Reply Last reply 29 Apr 2021, 18:27
          0
          • R RogerBreton
            29 Apr 2021, 18:17

            @JonB I don't dare say RB_StartMeasurement may be a nullptr in ALL LIKELIHOOD, and that maybe the cause of the segmentation fault. That is exactly my hypothesis. So, if that is the case, this proves my intuition : where is the application getting the DLL from? If its name isn't specified anywhere? It is not in the PRO file.

            I was thinking, perhaps, I should test whether the library is loaded before calling RB_StartMeasurement? And if it is not loaded, then load it? But that would not explain why I get the SIGSEV when the application tries to load? Or is it happening in the constructor?

            Somehow, I must be missing some important piece of the puzzle -- I'll continue to look around but I am optimistic...

            J Offline
            J Offline
            JonB
            wrote on 29 Apr 2021, 18:27 last edited by
            #18

            @RogerBreton

            bool Result;
            Result = myLib.load();
            if (!Result)
                qDebug() << "This is bad...";
            RB_StartMeasurement = reinterpret_cast<Fn6>(myLib.resolve("FDX_StartMeasurement"));
            if (RB_StartMeasurement  == nullptr)
                qDebug() << "This is bad.  Get ready for SEGV if you call RB_StartMeasurement() now...";
            sdkError = RB_StartMeasurement();
            
            1 Reply Last reply
            0
            • R Offline
              R Offline
              RogerBreton
              wrote on 29 Apr 2021, 18:29 last edited by
              #19

              I declared the RB_StartMeasurement as NULL in mainwindow.h :

              class MainWindow : public QMainWindow
              {
                  Q_OBJECT
                  QLibrary myLib;
              
                  typedef DEVICE_ERROR_TYPES(__stdcall* Fn6)(void);
                  Fn6 RB_StartMeasurement = NULL;
              
              

              But I still get the Segmentation Fault...

              Roger Breton
              www.graxx.ca

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 29 Apr 2021, 18:31 last edited by
                #20

                Hi,

                Did you implement @JonB´s suggestion ?

                Start in debug and you should see exactly where it fails.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                R 1 Reply Last reply 29 Apr 2021, 19:11
                0
                • S SGaist
                  29 Apr 2021, 18:31

                  Hi,

                  Did you implement @JonB´s suggestion ?

                  Start in debug and you should see exactly where it fails.

                  R Offline
                  R Offline
                  RogerBreton
                  wrote on 29 Apr 2021, 19:11 last edited by
                  #21

                  @SGaist That is exactly what I do :

                  I found the culprit...

                  DEVICE_ERROR_TYPES sdkError = RB_RegisterDeviceEventHandler(EventNotice);
                  
                  

                  The above function is a static member function declared in SomeClassName... which was working fine before ... The EventNotice function is also part of the same class.

                  Roger Breton
                  www.graxx.ca

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    RogerBreton
                    wrote on 29 Apr 2021, 20:03 last edited by
                    #22

                    For some reason (?), the EventNotice "address" is garbage :

                    EventNotice 2372415452829272149 void (DEVICE_eEventCode, uint32_km, DEVICE_ERROR_TYPES)

                    It should be a proper address like 0x00007ff739a21970.
                    I tried restarting QT Creator many times to no avail.

                    Roger Breton
                    www.graxx.ca

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      RogerBreton
                      wrote on 29 Apr 2021, 23:31 last edited by
                      #23

                      Thank you all for your patient help.
                      I'm putting QT on the backburner for now.
                      Too bad. Such a nice environment.

                      Roger Breton
                      www.graxx.ca

                      1 Reply Last reply
                      0

                      23/23

                      29 Apr 2021, 23:31

                      • Login

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