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. [solved] SIGSEGV segmentation fault
Forum Updated to NodeBB v4.3 + New Features

[solved] SIGSEGV segmentation fault

Scheduled Pinned Locked Moved General and Desktop
17 Posts 4 Posters 8.2k 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.
  • A Offline
    A Offline
    asma11
    wrote on last edited by
    #5

    login.cpp:
    @#include "login.h"
    #include "ui_login.h"

    login::login(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::login)
    {
    ui->setupUi(this);
    QPixmap pic("C:/Users/asma/Desktop/mychat/client/login.png");
    ui->label_4->setPixmap(pic);

    if(!connOpen())
        ui->label_3->setText("failed to open database");
    else
        ui->label_3->setText("Connected");
    

    }

    login::~login()
    {
    delete ui;
    }

    void login::on_pushButton_clicked()
    {
    QString username, password;
    username = ui->lineEdit_username->text();
    password = ui->lineEdit_password->text();

    if(!connOpen())
    {
        qDebug()<<"failed to open database";
        return;
    }
    connOpen();
    QSqlQuery qry;
    //qry.prepare("select * from users where pseudo = '"+username+"' and mot_de_passe = '"+password+"'");
    qry.prepare("select * from users where pseudo = :username and mot_de_passe = :password");
                qry.bindValue(":username",username);
                qry.bindValue(":password",password);
    if (qry.exec&#40;&#41;)
    {
        int count=0;
        while(qry.next())
        {
            count++;
        }
        if(count==1)
        {
            ui->label_3->setText("username and password are correct");
            connClose();
            this->hide();
            client c;
            c.setModal(true);
            c.exec&#40;&#41;;
        }
        if(count<1)
        {
            ui->label_3->setText("username and password incorrect , veuillez s'inscrir");
            connClose();
            this->hide();
            inscription Inscription;
            Inscription.setModal(true);
            Inscription.exec&#40;&#41;;
        }
    
    }
    else qDebug()<< qry.lastError();
    

    }

    void login::on_pushButton_2_clicked()
    {
    this->hide();
    inscription Inscription;
    Inscription.setModal(true);
    Inscription.exec();
    }
    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      KushalAusula
      wrote on last edited by
      #6

      Hi,
      As far as I know this error could be caused due to accessing a NULL POINTER of invalid memory.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        KushalAusula
        wrote on last edited by
        #7

        Hi,
        As far as I know this error could be caused due to accessing a NULL POINTER or invalid memory.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Ildar
          wrote on last edited by
          #8

          What are type of listeMessages object? And are you initialize listeMessages?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            asma11
            wrote on last edited by
            #9

            Hi , listeMessages is a QTextBrowser

            1 Reply Last reply
            0
            • A Offline
              A Offline
              asma11
              wrote on last edited by
              #10

              i have changed s.th and now the debugger shows me that the ploblem is on line 33 :
              socket->connectToHost(serveurIP->text(), serveurPort->value());

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #11

                Hi,

                From the code you posted, neither serveurIP nor serveurPort are initialized

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

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  asma11
                  wrote on last edited by
                  #12

                  serveurIP is a QLineEdit ,serveurPort is a QDableSpinBox : both are inisialised in client.ui

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    Then, the calls should be

                    @socket->connectToHost(ui->serveurIP->text(), ui->serveurPort->value());@

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

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      asma11
                      wrote on last edited by
                      #14

                      it's ok i have solved this problem but now another error appaired it's related with socket i will create another discussion . Thanx everybody for help :)

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        So what was the problem ?

                        Since you solved it, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

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

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          asma11
                          wrote on last edited by
                          #16

                          Hi ,the problem was on: "socket->connectToHost(ui->serveurIP->text(), ui->serveurPort->value()); " on this line I forget to put ui-> as you told me @SGaist , thanx for help.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #17

                            What is strange is that this would compile, so I guess you have member variables with these names in your class ? If so remove you should remove them

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

                            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