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. Error accesing private member of a class inside a shared library
Forum Updated to NodeBB v4.3 + New Features

Error accesing private member of a class inside a shared library

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 6 Posters 3.4k 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.
  • J JR Leal
    30 Dec 2022, 18:04

    I have developed an application and shared libraries for a long time wirh Qt 5.14.2. Very recently I have been reported an error and I have found the point where the error occurs, but I can not find an explanation. The error occurs in a member function of a class that is inside a shared library. It turns out that when accessing a member variable of type QString, an exception occurs. Not even the debugger can access this variable.

    In shared library:

    class SHAPE_EXPORT Shape {
    private:
      QString m_name;
    ....
    }
    
    bool open(const QString &name) {
      m_name = name;
    ...
    }
    

    Error occurs on the line m_name = name. The same occurs if I write qDebug() << m_name;
    No error occurs accessing otrher int variables.

    I do not know that I have changed in the properties of the project if it will be a problem of an update or that, since until not long ago it worked perfectly.

    Any idea what may be going on? I can't think of what else to try.

    Thank you very much and happy new year!

    J Offline
    J Offline
    JonB
    wrote on 30 Dec 2022, 18:53 last edited by
    #3

    @JR-Leal
    In addition to answering @JoeCFD, can you reproduce the "exception" when running program under debugger? If so, it may or may not help, but what does the stack trace show?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JR Leal
      wrote on 30 Dec 2022, 19:21 last edited by
      #4

      The exception is:

      Stopped in thread 0 by Exception at 0x7ffe3d83185d, code 0x0000005: read access violation at: 0x0, flags=0x0 (first chance).

      The debugger show these call's:

      1 std::_Load_relaxed_4
      2 std::_Atomic_load_4
      3 std::atomic_load_explicit
      4 std::_Atomic_int::load
      5 QAtomicOps<int>::loadRelaxed<int>
      6 QBasicAtomicInteger<int>::loadRelaxed
      7 QtPrivate::RefCount::deref
      8 QString::operator=
      9 Shape::open
      

      If I inspect *this object whit Debugger, it show:
      m_name <not accessible>

      This code worked fine until not so long ago and I haven't touched it. The same thing is happening to me in other classes within the shared library, which I have not modified either. It may be some compiler or project option

      Thanks.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 30 Dec 2022, 19:30 last edited by
        #5

        @JR-Leal said in Error accesing private member of a class inside a shared library:

        Shape

        Please show from where you access it, also make sure the instance you use is properly instantiated (I would guess it's not)

        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
        0
        • J Offline
          J Offline
          JR Leal
          wrote on 30 Dec 2022, 19:48 last edited by
          #6

          Mi code using this class is very simple:

          Shape shape;
          if (!shape.open("locations.shp")) {
          ...
          

          The exception occurs in the m_name = name statement of the open function. The same thing happens if, for example, I put qDebug() << m_name in that function or in another function of the class. But, as I said, I suspect that the error is not in the code since it worked correctly until recently and also, it is happening to me in other classes of the shared library.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 30 Dec 2022, 20:00 last edited by
            #7

            Please provide some more code, with the complete call stack. Also do you use the same Qt version for your dll and your app?

            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
            0
            • J Offline
              J Offline
              JR Leal
              wrote on 30 Dec 2022, 20:35 last edited by
              #8

              @Christian-Ehrlicher , the code The code is the one I have set. Just add that the Shape constructor is the default constructor: Shape() = default;. I have put the call stack above.

              But, as I said, I think the code has no problems (as you can see it is very simple). This code worked perfectly until recently. In addition, the same thing is happening to me with other classes within the shared library. It must be something of project configuration, compiler configuration (MSVC 2017 64-bit) or something similar. I have quite a bit of experience programming in C++ and Qt in particular, and it's the first time I've come across a problem as simple and as absurd as this.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JR Leal
                wrote on 30 Dec 2022, 20:50 last edited by JR Leal
                #9

                By way of summary, and to clarify the problem:

                In shared library:

                class SHAPE_EXPORT Shape {
                private:
                  QString m_name;
                ...
                }
                
                bool Shape::open(const QString &name) {
                  m_name = name;
                ...
                }
                

                After invoking by:

                Shape shape;
                if (!shape.open("locations.shp")) {
                ...
                

                The line m_name = name throws an exception:
                Stopped in thread 0 by Exception at 0x7ffe3d83185d, code 0x0000005: read access violation at: 0x0, flags=0x0 (first chance).

                And the call stack:

                1 std::_Load_relaxed_4
                2 std::_Atomic_load_4
                3 std::atomic_load_explicit
                4 std::_Atomic_int::load
                5 QAtomicOps<int>::loadRelaxed<int>
                6 QBasicAtomicInteger<int>::loadRelaxed
                7 QtPrivate::RefCount::deref
                8 QString::operator=
                9 Shape::open
                

                If I change the library code to:

                class SHAPE_EXPORT Shape {
                private:
                  QString m_name;
                ...
                }
                
                bool Shape::open(const QString &name) {
                  qDebug() << m_name;
                ...
                }
                

                The same exception occurs. The call stack is now:

                1 QString::length
                2 QDebug::operator<<
                3 Shape::open
                

                Access to int-type variables does not cause exceptions.

                All the code (main program and shared library) are made qith Qt 5.14.2 with MSVC 2017 64bits. The .pro of the shared library is:

                QT += core gui
                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                CONFIG += qt windows no_batch
                win32:CONFIG += debug_and_release build_all
                CONFIG += shared
                CONFIG += c++17
                CONFIG += install_headers
                TEMPLATE = lib
                
                INCLUDEPATH += ..
                
                win32 {
                    QMAKE_CXXFLAGS += -utf-8
                
                    DEFINES += WIN32_LEAN_AND_MEAN _USE_MATH_DEFINES NOMINMAX _CRT_SECURE_NO_WARNINGS
                }
                
                TARGET = $$qtLibraryTarget(Shape)
                
                include(shape.pri)
                INSTALL_HEADERS     = $$HEADERS
                INSTALL_HEADERS    -= $$PRIVATE_HEADERS
                INSTALL_PREFIX      = $$[QT_INSTALL_HEADERS]/shape
                
                dlltarget.path      = $$[QT_INSTALL_BINS]
                INSTALLS           += dlltarget
                target.path         = $$[QT_INSTALL_LIBS]
                target.CONFIG       = no_dll
                INSTALLS           += target
                
                

                I think the code has no problems. Can be some configuration problem?

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  ChrisW67
                  wrote on 30 Dec 2022, 23:06 last edited by
                  #10

                  @JR-Leal said in Error accesing private member of a class inside a shared library:

                  In this code you have repeated several times now:

                  class SHAPE_EXPORT Shape {
                  private:
                    QString m_name;
                  ...
                  }
                  
                  bool open(const QString &name) {
                    qDebug() << m_name;
                  ...
                  }
                  

                  The function open() is not a member of Shape and therefore barred from accessing private member variables in that class. If this is actually your code it should fail to compile with a clear error message.

                  You appear to have something that compiles and can be run with a backtrace involving Shape::open().
                  You should share your actual code.

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    JR Leal
                    wrote on 30 Dec 2022, 23:46 last edited by JR Leal
                    #11

                    @ChrisW67 I'm sorry. The code is:

                    bool Shape::open(const QString &name) 
                    

                    My code is much more complex. I have write only a extract of it.

                    • I have fixed the occurrences of this member function in previous posts for greater code clarity
                    K 1 Reply Last reply 30 Dec 2022, 23:51
                    0
                    • J JR Leal
                      30 Dec 2022, 23:46

                      @ChrisW67 I'm sorry. The code is:

                      bool Shape::open(const QString &name) 
                      

                      My code is much more complex. I have write only a extract of it.

                      • I have fixed the occurrences of this member function in previous posts for greater code clarity
                      K Offline
                      K Offline
                      kshegunov
                      Moderators
                      wrote on 30 Dec 2022, 23:51 last edited by
                      #12

                      @JR-Leal said in Error accesing private member of a class inside a shared library:

                      My code is much more complex. I have write only a extract of it.

                      Yes, and by the look of the stack trace you're calling a method on an uninitialized object, looks like calling a dangling pointer.
                      I'm pretty sure this:

                      Shape shape;
                      if (!shape.open("locations.shp")) {
                      

                      Isn't how the call is made.
                      I'll repeat what others have asked: Provide more code, a complete example that (re)produces the problem.

                      Read and abide by the Qt Code of Conduct

                      J 1 Reply Last reply 31 Dec 2022, 00:15
                      0
                      • K kshegunov
                        30 Dec 2022, 23:51

                        @JR-Leal said in Error accesing private member of a class inside a shared library:

                        My code is much more complex. I have write only a extract of it.

                        Yes, and by the look of the stack trace you're calling a method on an uninitialized object, looks like calling a dangling pointer.
                        I'm pretty sure this:

                        Shape shape;
                        if (!shape.open("locations.shp")) {
                        

                        Isn't how the call is made.
                        I'll repeat what others have asked: Provide more code, a complete example that (re)produces the problem.

                        J Offline
                        J Offline
                        JR Leal
                        wrote on 31 Dec 2022, 00:15 last edited by
                        #13

                        @kshegunov This code is just as I have put. Although it seems absurd, such simple pieces of code generate that exception, if the Shape class is in a shared library. If I use it directly (without libraries) the code works well.
                        In addition, the code worked perfectly and I have not modified it. This same problem has happened to me in other classes of the shared library. That's why I think it's a configuration problem.

                        Shape shape;
                        if (!shape.open("locations.shp")) {
                        

                        This portion of code is 100% equal to my code.

                        K 1 Reply Last reply 31 Dec 2022, 00:39
                        0
                        • J JR Leal
                          31 Dec 2022, 00:15

                          @kshegunov This code is just as I have put. Although it seems absurd, such simple pieces of code generate that exception, if the Shape class is in a shared library. If I use it directly (without libraries) the code works well.
                          In addition, the code worked perfectly and I have not modified it. This same problem has happened to me in other classes of the shared library. That's why I think it's a configuration problem.

                          Shape shape;
                          if (!shape.open("locations.shp")) {
                          

                          This portion of code is 100% equal to my code.

                          K Offline
                          K Offline
                          kshegunov
                          Moderators
                          wrote on 31 Dec 2022, 00:39 last edited by kshegunov
                          #14

                          @JR-Leal said in Error accesing private member of a class inside a shared library:

                          This code is just as I have put. Although it seems absurd, such simple pieces of code generate that exception, if the Shape class is in a shared library. If I use it directly (without libraries) the code works well.

                          Fine. The fact remains that the top of the call stack looks like a dereferencing an invalid address. Show a full stack trace of the crash (and I don't just mean one staring from ::open); I want to see the bottom of the call stack. And with file names and line numbers.

                          Read and abide by the Qt Code of Conduct

                          J 1 Reply Last reply 31 Dec 2022, 01:02
                          0
                          • K kshegunov
                            31 Dec 2022, 00:39

                            @JR-Leal said in Error accesing private member of a class inside a shared library:

                            This code is just as I have put. Although it seems absurd, such simple pieces of code generate that exception, if the Shape class is in a shared library. If I use it directly (without libraries) the code works well.

                            Fine. The fact remains that the top of the call stack looks like a dereferencing an invalid address. Show a full stack trace of the crash (and I don't just mean one staring from ::open); I want to see the bottom of the call stack. And with file names and line numbers.

                            J Offline
                            J Offline
                            JR Leal
                            wrote on 31 Dec 2022, 01:02 last edited by JR Leal
                            #15

                            @kshegunov Here you have both stacks. One with qDebug() << m_name;
                            bece7243-4c56-49db-9f10-baf7d18e00f9-imagen.png

                            and one with m_name = name:
                            e9c60051-b4f2-4c92-9c8f-d8375ec433a7-imagen.png

                            It is clear to me that the error seems to be trying to access an uninitialized object, but this is not the case. In fact, I can access other properties of type int, bool, without problems.

                            And I repeat, at the risk of sounding heavy, that the same thing is happening to me with other classes within the shared library, when until not long ago they worked perfectly.

                            C K 2 Replies Last reply 31 Dec 2022, 01:30
                            0
                            • J JR Leal
                              31 Dec 2022, 01:02

                              @kshegunov Here you have both stacks. One with qDebug() << m_name;
                              bece7243-4c56-49db-9f10-baf7d18e00f9-imagen.png

                              and one with m_name = name:
                              e9c60051-b4f2-4c92-9c8f-d8375ec433a7-imagen.png

                              It is clear to me that the error seems to be trying to access an uninitialized object, but this is not the case. In fact, I can access other properties of type int, bool, without problems.

                              And I repeat, at the risk of sounding heavy, that the same thing is happening to me with other classes within the shared library, when until not long ago they worked perfectly.

                              C Offline
                              C Offline
                              ChrisW67
                              wrote on 31 Dec 2022, 01:30 last edited by
                              #16

                              @JR-Leal said in Error accesing private member of a class inside a shared library:

                              when until not long ago they worked perfectly.

                              Then what changed "not long ago"?

                              Have you thrown away the build directory to be absolutely sure you have a clean build without mismatched components?

                              Since your code is inside a shared library:
                              Did you change the binary interface of any of the the classes involved in your library?
                              Have you rebuilt the executable you are running against the freshly built library?

                              1 Reply Last reply
                              0
                              • J JR Leal
                                31 Dec 2022, 01:02

                                @kshegunov Here you have both stacks. One with qDebug() << m_name;
                                bece7243-4c56-49db-9f10-baf7d18e00f9-imagen.png

                                and one with m_name = name:
                                e9c60051-b4f2-4c92-9c8f-d8375ec433a7-imagen.png

                                It is clear to me that the error seems to be trying to access an uninitialized object, but this is not the case. In fact, I can access other properties of type int, bool, without problems.

                                And I repeat, at the risk of sounding heavy, that the same thing is happening to me with other classes within the shared library, when until not long ago they worked perfectly.

                                K Offline
                                K Offline
                                kshegunov
                                Moderators
                                wrote on 31 Dec 2022, 09:50 last edited by
                                #17

                                @JR-Leal said in Error accesing private member of a class inside a shared library:

                                @kshegunov Here you have both stacks.

                                Thank you, I'm interested only in the one generated by the assignment, however it is incomplete. I asked that the bottom of the stack should be visible. What I see here is that this is called in a textChanged signal handler and not much more. I'd rather be able to trace the whole call chain ...

                                It is clear to me that the error seems to be trying to access an uninitialized object, but this is not the case. In fact, I can access other properties of type int, bool, without problems.

                                This means absolutely nothing. You can read primitive types from unowned memory all you want. If the value that they the memory had held was what you expected, you'd even read sensible values ...

                                And I repeat, at the risk of sounding heavy, that the same thing is happening to me with other classes within the shared library, when until not long ago they worked perfectly.

                                Fine. Then what @ChrisW67 asked - something changed, so what did?

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                1
                                • J Offline
                                  J Offline
                                  JR Leal
                                  wrote on 31 Dec 2022, 10:48 last edited by JR Leal
                                  #18

                                  @ChrisW67 , @kshegunov The problem is that I have changed many things. The software has been constantly evolving. And now I've been notified of this error, and I've been told that it's been a long time since it's been a while. In addition to fixing bugs, improving functionality and adding new ones, I have changed from C++14 to C++17 in the compiler options (but I have not changed the compiler version, it is still MSVC 2017 64-bit). I do not remember changing any other options (and in subversion I have not found other modifications).

                                  I'm going to try creating a new, extremely simple class in the shared library and see if it gives me the same problems.

                                  As for the call stack, it is very long. The event is triggered inside a dialog box, so there is previously the creation part of it. Here you can see the following lines:

                                  fe251dda-d43b-4605-9a10-66e48ec242fe-imagen.png
                                  da86dfc1-5255-4990-abba-31e19a6f75f5-imagen.png
                                  ff215fdf-4bba-4388-9ea1-7bea9a78c93b-imagen.png

                                  K 1 Reply Last reply 31 Dec 2022, 10:56
                                  0
                                  • J JR Leal
                                    31 Dec 2022, 10:48

                                    @ChrisW67 , @kshegunov The problem is that I have changed many things. The software has been constantly evolving. And now I've been notified of this error, and I've been told that it's been a long time since it's been a while. In addition to fixing bugs, improving functionality and adding new ones, I have changed from C++14 to C++17 in the compiler options (but I have not changed the compiler version, it is still MSVC 2017 64-bit). I do not remember changing any other options (and in subversion I have not found other modifications).

                                    I'm going to try creating a new, extremely simple class in the shared library and see if it gives me the same problems.

                                    As for the call stack, it is very long. The event is triggered inside a dialog box, so there is previously the creation part of it. Here you can see the following lines:

                                    fe251dda-d43b-4605-9a10-66e48ec242fe-imagen.png
                                    da86dfc1-5255-4990-abba-31e19a6f75f5-imagen.png
                                    ff215fdf-4bba-4388-9ea1-7bea9a78c93b-imagen.png

                                    K Offline
                                    K Offline
                                    kshegunov
                                    Moderators
                                    wrote on 31 Dec 2022, 10:56 last edited by kshegunov
                                    #19

                                    @JR-Leal said in Error accesing private member of a class inside a shared library:

                                    As for the call stack, it is very long. The event is triggered inside a dialog box, so there is previously the creation part of it. Here you can see the following lines:

                                    Yes, I suggest you extract it as text from Creator. ;)
                                    Do you mind showing what sits around (5-10 lines before and after) line 31 in MenuHerramientas.cpp, where you open the dialog. Also put a breakpoint in the dialog destructor to make sure. Additionally, please show the lambda (exactly as it appears in the code) that's connected to the clicked signal, the one that calls QLineEdit::setText.

                                    Read and abide by the Qt Code of Conduct

                                    J 1 Reply Last reply 31 Dec 2022, 11:18
                                    0
                                    • K kshegunov
                                      31 Dec 2022, 10:56

                                      @JR-Leal said in Error accesing private member of a class inside a shared library:

                                      As for the call stack, it is very long. The event is triggered inside a dialog box, so there is previously the creation part of it. Here you can see the following lines:

                                      Yes, I suggest you extract it as text from Creator. ;)
                                      Do you mind showing what sits around (5-10 lines before and after) line 31 in MenuHerramientas.cpp, where you open the dialog. Also put a breakpoint in the dialog destructor to make sure. Additionally, please show the lambda (exactly as it appears in the code) that's connected to the clicked signal, the one that calls QLineEdit::setText.

                                      J Offline
                                      J Offline
                                      JR Leal
                                      wrote on 31 Dec 2022, 11:18 last edited by JR Leal
                                      #20

                                      @kshegunov It hadn't occurred to me that you can copy the contents of the call stack as text, sorry.

                                      Complete call stack:

                                      1   std::_Load_relaxed_4                                                                                                                         xatomic.h                      1341 0x7ffe3d62a87e 
                                      2   std::_Atomic_load_4                                                                                                                          xatomic.h                      1360 0x7ffe3d629aed 
                                      3   std::atomic_load_explicit                                                                                                                    xxatomic                       495  0x7ffe3d62c9d7 
                                      4   std::_Atomic_int::load                                                                                                                       xxatomic                       630  0x7ffe3d6318ab 
                                      5   QAtomicOps<int>::loadRelaxed<int>                                                                                                            qatomic_cxx11.h                240  0x7ffe3d624a25 
                                      6   QBasicAtomicInteger<int>::loadRelaxed                                                                                                        qbasicatomic.h                 107  0x7ffe3d6318d6 
                                      7   QtPrivate::RefCount::deref                                                                                                                   qrefcount.h                    66   0x7ffe3d62ee66 
                                      8   QString::operator=                                                                                                                           qstring.cpp                    2398 0x7ffe3d84aed2 
                                      9   amatel::Shape::abre                                                                                                                          Shape.cpp                      88   0x7ffee76f3c6f 
                                      10  DlgShp2Tif::onTextChanged                                                                                                                    DlgShp2Tif.cpp                 220  0x7ff6a7776f09 
                                      11  QtPrivate::FunctorCall<QtPrivate::IndexesList<0>,QtPrivate::List<QString const &>,void,void (__cdecl DlgShp2Tif:: *)(QString const &)>::call qobjectdefs_impl.h             152  0x7ff6a777c4ae 
                                      12  QtPrivate::FunctionPointer<void (__cdecl DlgShp2Tif:: *)(QString const &)>::call<QtPrivate::List<QString const &>,void>                      qobjectdefs_impl.h             186  0x7ff6a7778d3d 
                                      13  QtPrivate::QSlotObject<void (__cdecl DlgShp2Tif:: *)(QString const &),QtPrivate::List<QString const &>,void>::impl                           qobjectdefs_impl.h             419  0x7ff6a777d21d 
                                      14  QtPrivate::QSlotObjectBase::call                                                                                                             qobjectdefs_impl.h             398  0x7ffe3daccd22 
                                      15  doActivate<0>                                                                                                                                qobject.cpp                    3870 0x7ffe3db2548c 
                                      16  QMetaObject::activate                                                                                                                        qobject.cpp                    3931 0x7ffe3db12d77 
                                      17  QLineEdit::textChanged                                                                                                                       moc_qlineedit.cpp              448  0x7ffe3f5e9110 
                                      18  QLineEdit::qt_static_metacall                                                                                                                moc_qlineedit.cpp              255  0x7ffe3f5e4542 
                                      19  doActivate<0>                                                                                                                                qobject.cpp                    3885 0x7ffe3db255a3 
                                      20  QMetaObject::activate                                                                                                                        qobject.cpp                    3931 0x7ffe3db12d77 
                                      21  QWidgetLineControl::textChanged                                                                                                              moc_qwidgetlinecontrol_p.cpp   274  0x7ffe3f5f8ac3 
                                      22  QWidgetLineControl::finishChange                                                                                                             qwidgetlinecontrol.cpp         737  0x7ffe3f5f61c1 
                                      23  QWidgetLineControl::internalSetText                                                                                                          qwidgetlinecontrol.cpp         772  0x7ffe3f5f4559 
                                      24  QWidgetLineControl::setText                                                                                                                  qwidgetlinecontrol_p.h         252  0x7ffe3f580126 
                                      25  QLineEditPrivate::setText                                                                                                                    qlineedit_p.cpp                277  0x7ffe3f5dde57 
                                      26  QLineEdit::setText                                                                                                                           qlineedit.cpp                  319  0x7ffe3f5e749c 
                                      27  <lambda_98a6b26bf0d27f8737cd826cc5a9a62a>::operator()                                                                                        DlgShp2Tif.cpp                 58   0x7ff6a777b6c0 
                                      28  QtPrivate::FunctorCall<QtPrivate::IndexesList<>,QtPrivate::List<>,void,<lambda_98a6b26bf0d27f8737cd826cc5a9a62a>>::call                      qobjectdefs_impl.h             146  0x7ff6a777c8a8 
                                      29  QtPrivate::Functor<<lambda_98a6b26bf0d27f8737cd826cc5a9a62a>,0>::call<QtPrivate::List<>,void>                                                qobjectdefs_impl.h             257  0x7ff6a7778c92 
                                      30  QtPrivate::QFunctorSlotObject<<lambda_98a6b26bf0d27f8737cd826cc5a9a62a>,0,QtPrivate::List<>,void>::impl                                      qobjectdefs_impl.h             449  0x7ff6a777ce87 
                                      31  QtPrivate::QSlotObjectBase::call                                                                                                             qobjectdefs_impl.h             398  0x7ffe3daccd22 
                                      32  doActivate<0>                                                                                                                                qobject.cpp                    3870 0x7ffe3db2548c 
                                      33  QMetaObject::activate                                                                                                                        qobject.cpp                    3931 0x7ffe3db12d77 
                                      34  QAbstractButton::clicked                                                                                                                     moc_qabstractbutton.cpp        314  0x7ffe3f541e02 
                                      35  QAbstractButtonPrivate::emitClicked                                                                                                          qabstractbutton.cpp            417  0x7ffe3f544054 
                                      36  QAbstractButtonPrivate::click                                                                                                                qabstractbutton.cpp            409  0x7ffe3f543024 
                                      37  QAbstractButton::mouseReleaseEvent                                                                                                           qabstractbutton.cpp            1013 0x7ffe3f5425f1 
                                      38  QToolButton::mouseReleaseEvent                                                                                                               qtoolbutton.cpp                623  0x7ffe3f7105dc 
                                      39  QWidget::event                                                                                                                               qwidget.cpp                    8660 0x7ffe3f3c4fcf 
                                      40  QAbstractButton::event                                                                                                                       qabstractbutton.cpp            970  0x7ffe3f542052 
                                      41  QToolButton::event                                                                                                                           qtoolbutton.cpp                1003 0x7ffe3f710424 
                                      42  QApplicationPrivate::notify_helper                                                                                                           qapplication.cpp               3685 0x7ffe3f362c4f 
                                      43  QApplication::notify                                                                                                                         qapplication.cpp               3129 0x7ffe3f35d6f4 
                                      44  QCoreApplication::notifyInternal2                                                                                                            qcoreapplication.cpp           1075 0x7ffe3dab2aa0 
                                      45  QCoreApplication::sendSpontaneousEvent                                                                                                       qcoreapplication.cpp           1483 0x7ffe3dab293b 
                                      46  QApplicationPrivate::sendMouseEvent                                                                                                          qapplication.cpp               2615 0x7ffe3f3656c2 
                                      47  QWidgetWindow::handleMouseEvent                                                                                                              qwidgetwindow.cpp              675  0x7ffe3f417b18 
                                      48  QWidgetWindow::event                                                                                                                         qwidgetwindow.cpp              296  0x7ffe3f415e31 
                                      49  QApplicationPrivate::notify_helper                                                                                                           qapplication.cpp               3685 0x7ffe3f362c4f 
                                      50  QApplication::notify                                                                                                                         qapplication.cpp               3025 0x7ffe3f35ce07 
                                      51  QCoreApplication::notifyInternal2                                                                                                            qcoreapplication.cpp           1075 0x7ffe3dab2aa0 
                                      52  QCoreApplication::sendSpontaneousEvent                                                                                                       qcoreapplication.cpp           1483 0x7ffe3dab293b 
                                      53  QGuiApplicationPrivate::processMouseEvent                                                                                                    qguiapplication.cpp            2204 0x7ffe3e3b6b64 
                                      54  QGuiApplicationPrivate::processWindowSystemEvent                                                                                             qguiapplication.cpp            1936 0x7ffe3e3ba116 
                                      55  QWindowSystemInterface::sendWindowSystemEvents                                                                                               qwindowsysteminterface.cpp     1176 0x7ffe3e384602 
                                      56  QWindowsGuiEventDispatcher::sendPostedEvents                                                                                                 qwindowsguieventdispatcher.cpp 83   0x7ffe36c867d2 
                                      57  QEventDispatcherWin32::processEvents                                                                                                         qeventdispatcher_win.cpp       525  0x7ffe3db84b6e 
                                      58  QWindowsGuiEventDispatcher::processEvents                                                                                                    qwindowsguieventdispatcher.cpp 74   0x7ffe36c86784 
                                      59  QEventLoop::processEvents                                                                                                                    qeventloop.cpp                 139  0x7ffe3daad1cd 
                                      60  QEventLoop::exec                                                                                                                             qeventloop.cpp                 225  0x7ffe3daad41f 
                                      61  QDialog::exec                                                                                                                                qdialog.cpp                    602  0x7ffe3f744eff 
                                      62  MainWindow::onConvertirShapes                                                                                                                MenuHerramientas.cpp           31   0x7ff6a7839546 
                                      63  QtPrivate::FunctorCall<QtPrivate::IndexesList<>,QtPrivate::List<>,void,void (__cdecl MainWindow:: *)(void)>::call                            qobjectdefs_impl.h             152  0x7ff6a78151eb 
                                      64  QtPrivate::FunctionPointer<void (__cdecl MainWindow:: *)(void)>::call<QtPrivate::List<>,void>                                                qobjectdefs_impl.h             186  0x7ff6a780b8ad 
                                      65  QtPrivate::QSlotObject<void (__cdecl MainWindow:: *)(void),QtPrivate::List<>,void>::impl                                                     qobjectdefs_impl.h             419  0x7ff6a7816ccd 
                                      66  QtPrivate::QSlotObjectBase::call                                                                                                             qobjectdefs_impl.h             398  0x7ffe3daccd22 
                                      67  doActivate<0>                                                                                                                                qobject.cpp                    3870 0x7ffe3db2548c 
                                      68  QMetaObject::activate                                                                                                                        qobject.cpp                    3931 0x7ffe3db12d77 
                                      69  QAction::triggered                                                                                                                           moc_qaction.cpp                382  0x7ffe3f338232 
                                      70  QAction::activate                                                                                                                            qaction.cpp                    1162 0x7ffe3f337549 
                                      71  QMenuPrivate::activateCausedStack                                                                                                            qmenu.cpp                      1355 0x7ffe3f65b7c3 
                                      72  QMenuPrivate::activateAction                                                                                                                 qmenu.cpp                      1433 0x7ffe3f65b6a4 
                                      73  QMenu::mouseReleaseEvent                                                                                                                     qmenu.cpp                      2911 0x7ffe3f6522e0 
                                      74  QWidget::event                                                                                                                               qwidget.cpp                    8660 0x7ffe3f3c4fcf 
                                      75  QMenu::event                                                                                                                                 qmenu.cpp                      3033 0x7ffe3f654b29 
                                      76  QApplicationPrivate::notify_helper                                                                                                           qapplication.cpp               3685 0x7ffe3f362c4f 
                                      77  QApplication::notify                                                                                                                         qapplication.cpp               3129 0x7ffe3f35d6f4 
                                      78  QCoreApplication::notifyInternal2                                                                                                            qcoreapplication.cpp           1075 0x7ffe3dab2aa0 
                                      79  QCoreApplication::sendSpontaneousEvent                                                                                                       qcoreapplication.cpp           1483 0x7ffe3dab293b 
                                      80  QApplicationPrivate::sendMouseEvent                                                                                                          qapplication.cpp               2615 0x7ffe3f3656c2 
                                      81  QWidgetWindow::handleMouseEvent                                                                                                              qwidgetwindow.cpp              573  0x7ffe3f416ed8 
                                      82  QWidgetWindow::event                                                                                                                         qwidgetwindow.cpp              296  0x7ffe3f415e31 
                                      83  QApplicationPrivate::notify_helper                                                                                                           qapplication.cpp               3685 0x7ffe3f362c4f 
                                      84  QApplication::notify                                                                                                                         qapplication.cpp               3025 0x7ffe3f35ce07 
                                      85  QCoreApplication::notifyInternal2                                                                                                            qcoreapplication.cpp           1075 0x7ffe3dab2aa0 
                                      86  QCoreApplication::sendSpontaneousEvent                                                                                                       qcoreapplication.cpp           1483 0x7ffe3dab293b 
                                      87  QGuiApplicationPrivate::processMouseEvent                                                                                                    qguiapplication.cpp            2204 0x7ffe3e3b6b64 
                                      88  QGuiApplicationPrivate::processWindowSystemEvent                                                                                             qguiapplication.cpp            1936 0x7ffe3e3ba116 
                                      89  QWindowSystemInterface::sendWindowSystemEvents                                                                                               qwindowsysteminterface.cpp     1176 0x7ffe3e384602 
                                      90  QWindowsGuiEventDispatcher::sendPostedEvents                                                                                                 qwindowsguieventdispatcher.cpp 83   0x7ffe36c867d2 
                                      91  QEventDispatcherWin32::processEvents                                                                                                         qeventdispatcher_win.cpp       525  0x7ffe3db84b6e 
                                      92  QWindowsGuiEventDispatcher::processEvents                                                                                                    qwindowsguieventdispatcher.cpp 74   0x7ffe36c86784 
                                      93  QEventLoop::processEvents                                                                                                                    qeventloop.cpp                 139  0x7ffe3daad1cd 
                                      94  QEventLoop::exec                                                                                                                             qeventloop.cpp                 225  0x7ffe3daad41f 
                                      95  QCoreApplication::exec                                                                                                                       qcoreapplication.cpp           1383 0x7ffe3dab076a 
                                      96  QGuiApplication::exec                                                                                                                        qguiapplication.cpp            1861 0x7ffe3e3b2aa8 
                                      97  QApplication::exec                                                                                                                           qapplication.cpp               2826 0x7ffe3f35c71a 
                                      98  main                                                                                                                                         main.cpp                       148  0x7ff6a7587089 
                                      99  WinMain                                                                                                                                      qtmain_win.cpp                 97   0x7ff6a7910c05 
                                      100 invoke_main                                                                                                                                  exe_common.inl                 107  0x7ff6a790f23d 
                                      101 __scrt_common_main_seh                                                                                                                       exe_common.inl                 288  0x7ff6a790f12e 
                                      102 __scrt_common_main                                                                                                                           exe_common.inl                 331  0x7ff6a790efee 
                                      103 WinMainCRTStartup                                                                                                                            exe_winmain.cpp                17   0x7ff6a790f2c9 
                                      104 BaseThreadInitThunk                                                                                                                          KERNEL32                            0x7fff010e7614 
                                      105 RtlUserThreadStart                                                                                                                           ntdll                               0x7fff02c026a1 
                                      
                                      

                                      MenuHerramientas.cpp, starting in line 29:

                                      void MainWindow::onConvertirShapes() {
                                        DlgShp2Tif dlgShp2Tif(this);
                                        if (dlgShp2Tif.exec() == QDialog::Accepted) {
                                          QString strShape, strImage;
                                          uint fieldNo;
                                          QString ficheroModelos;
                                          crs::CoordinateSystem crsIn, crsOut;
                                          double pixelYSize, pixelXSize;
                                          dlgShp2Tif.values(strShape, fieldNo, crsIn, ficheroModelos,
                                                            pixelXSize, pixelYSize, crsOut, strImage);
                                      
                                          QString nombreShape, nombreImagen, extension;
                                          splitPath(strShape, nombreShape, extension);
                                          splitPath(strImage, nombreImagen, extension);
                                      
                                      

                                      And the lambda function:

                                        connect(ui->btnShape, &QToolButton::clicked, this, [=]() {
                                          QString nombre = QFileDialog::getOpenFileName(this, tr("Seleccione fichero Shape"),
                                                                                        s_shape, tr("Ficheros shape (*.shp)"),
                                                                                        nullptr, QFileDialog::ReadOnly);
                                          if (!nombre.isEmpty()) {
                                            ui->shape->setText(nombre);
                                          }
                                        });
                                      
                                      

                                      I have put the breakpoint on the destructor, and as expected, it has not been invoked.

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        JR Leal
                                        wrote on 31 Dec 2022, 15:53 last edited by
                                        #21

                                        Finally, it has fixed the problem, although I still do not know the cause. I deleted the build directories of both the application and the shared library, reconfigured the project, and build everything. As a result, it works again.

                                        Many thanks to those who have tried to help me.

                                        1 Reply Last reply
                                        1

                                        12/21

                                        30 Dec 2022, 23:51

                                        • Login

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