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. Access to Object / various errors
Forum Updated to NodeBB v4.3 + New Features

Access to Object / various errors

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StephanWoebbeking
    wrote on last edited by
    #1

    Hi,

    I have created a fairly easy demonstration project to investigate a much bigger project I am working at. So there are some unused fields and so on, but I think that should be no harm for the technical issues I have with it.

    Funnily, there are various errors, I have quite some trouble to describe the different states. My first approach would be to confirm, that someone else has problems as well and its not in my installation or something.

    I have only 5 files:
    main.cpp
    mainwindow.h and .cpp
    state.h and .cpp

    main.cpp:

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }
    
    

    mainwindow.h:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <state.h>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
        state windowState;
    };
    
    #endif // MAINWINDOW_H
    

    mainwindow.cpp:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        windowState.append( 0x73 );
        windowState.data.append( 0x74 );
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    

    state.h:

    #ifndef STATE_H
    #define STATE_H
    
    #include <QString>
    #include <QByteArray>
    
    class state
    {
    public:
        state();
    
        void append( char appData );
    
        QByteArray data;
        int dummy; // try to delete this
        QString errorString; // next, try to push this to be before the QByteArray
    };
    
    #endif // STATE_H
    

    state.cpp:

    #include "state.h"
    
    state::state() {}
    
    void state::append(char appData){
        data.append( appData );
    }
    

    It doesn't really do anything, all it does for me is crushing. Can somebody confirm this or is it only for me?

    Next, there are three things I have done to make the whole even more interesting. In state.h change:

    1. Remove the "int dummy;" field
    2. Replace the "QString errorString;" to be before the QByteArray
    3. Remove the "QString errorString;" at all

    I would be more than interested in finding how this behaves for you?

    Thanks a lot,
    Stephan

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      First I just ran it.
      Then tried to both delete the dummy and move the QString.
      No crashes.

      https://www.dropbox.com/s/yts645v45n0ugnl/Testcrash.zip?dl=0
      In case others want to try.

      S 1 Reply Last reply
      1
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Where does it crash?

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

        S 1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          First I just ran it.
          Then tried to both delete the dummy and move the QString.
          No crashes.

          https://www.dropbox.com/s/yts645v45n0ugnl/Testcrash.zip?dl=0
          In case others want to try.

          S Offline
          S Offline
          StephanWoebbeking
          wrote on last edited by
          #4

          Hi mrjj, sorry, I could have packed the project myself and saved you that part of work, didn't think of it... On the other hand, it gave me some conclusions...

          Even it seems not logical, I downloaded your project, it looks pretty much exactly like mine, but yours didn't crush while mine still does / did. So I looked for differences, obviously. The only difference - besides the name of the project - was the build path which, in my project, was configured to be within the projects directory. Pushed that to the parent, now it works fine... Never thought this could be a reason for the errors I received...

          Thanks!
          Stephan

          mrjjM 1 Reply Last reply
          0
          • S StephanWoebbeking

            Hi mrjj, sorry, I could have packed the project myself and saved you that part of work, didn't think of it... On the other hand, it gave me some conclusions...

            Even it seems not logical, I downloaded your project, it looks pretty much exactly like mine, but yours didn't crush while mine still does / did. So I looked for differences, obviously. The only difference - besides the name of the project - was the build path which, in my project, was configured to be within the projects directory. Pushed that to the parent, now it works fine... Never thought this could be a reason for the errors I received...

            Thanks!
            Stephan

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @StephanWoebbeking
            Ok. that is good news even I do wonder
            why.
            There must been something old in the last
            build folder. (which was now rebuild)
            But my Imagination fails to understand how
            it could have made u crash.

            1 Reply Last reply
            0
            • jsulmJ jsulm

              Where does it crash?

              S Offline
              S Offline
              StephanWoebbeking
              wrote on last edited by
              #6

              Hi jsulm,

              well, I received a "application terminated in an unusual way" error without any location. After removing the "int dummy" I received a segmentation fault within the generated ui code.

              I "invented" this to reproduce the segmentation fault errors we have already discussed in another thread. Now, I was successfully reproducing it as it looked pretty much similar. But for my real project, the build directory is NOT in the project directory, so I still don't know what to do...

              But what I found already is, that my initial error (from the other thread) can be solved but switching the variable definition before all other variables... I am somehow lost here...

              Best Regards,
              Stephan

              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                it does sounds like moc generate
                something in your ui_mainwindow
                that makes you crash.

                I was wondering:

                If u look in old location for build (for mini sample)
                where is still crashes and look at the ui_ file
                and then compare new build folder where it doesn't crash.

                Are they the same ?

                S 1 Reply Last reply
                0
                • mrjjM mrjj

                  Hi
                  it does sounds like moc generate
                  something in your ui_mainwindow
                  that makes you crash.

                  I was wondering:

                  If u look in old location for build (for mini sample)
                  where is still crashes and look at the ui_ file
                  and then compare new build folder where it doesn't crash.

                  Are they the same ?

                  S Offline
                  S Offline
                  StephanWoebbeking
                  wrote on last edited by
                  #8

                  Hi, there is no ui_mainwindow file in the directory? Actually I have changed my folder structure now; it wasn't really my intention to place it into the project directory, so I corrected this and since then I am not able to reproduce the error I had.

                  Well, that's good news from one point, but the bad point is that I wanted to reproduce an error from my big project and now I don't know any more, what else to put into the small project to get the error...

                  Stephan

                  mrjjM 1 Reply Last reply
                  0
                  • S StephanWoebbeking

                    Hi, there is no ui_mainwindow file in the directory? Actually I have changed my folder structure now; it wasn't really my intention to place it into the project directory, so I corrected this and since then I am not able to reproduce the error I had.

                    Well, that's good news from one point, but the bad point is that I wanted to reproduce an error from my big project and now I don't know any more, what else to put into the small project to get the error...

                    Stephan

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Well if you cannot reproduce the error in small project then
                    it must have been some odd stuff and not actually the code.

                    If you can reproduce in big project then maybe look at other areas then the code
                    in small project.

                    Sadly we cannot really help as its near impossible to give advice to as it can be anything.

                    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