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. Application crashes when mouse moves
Forum Updated to NodeBB v4.3 + New Features

Application crashes when mouse moves

Scheduled Pinned Locked Moved General and Desktop
22 Posts 2 Posters 8.9k 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
    SherifOmran
    wrote on last edited by
    #21

    In the main module called typingmain, i do the following with the practiseform

    typingmain.cpp
    @
    QPointer <practising> practiseform = new practising(true,1,0,0); // practise mode, default lesson min=1, lessonmax=0, new parent window=0
    practiseform->mainparentform=this; connect(practiseform.data(),SIGNAL(ToTypingDeletePractise(int)),this,SLOT(CloseChild(int));
    this->hide();
    int x=practiseform->exec();
    if (qDebugDemo>=2) {qDebug() << "returned back";}
    this->show();
    if (qDebugDemo>=1) {qDebug () << "practise finished with return =" << x << " is window reset?" << practiseform.isNull();}
    if (! practiseform.isNull())
    {
    qDebug() << "delete practiseform";
    //delete practiseform;
    }
    @

    In practising, i load the handpop when a button is clicked
    practising.cpp
    @
    if (!handwindowenabled)
    {
    handpop = new practisehandwin(0);
    //connect(this,SIGNAL(destroyed()),handpop.data(),SLOT(close()));
    //QScopedPointer<practisehandwin> handpop(new practisehandwin(0));
    }
    @

    Then when it closes, i delete the handpop and emit a signal back to typingmain to delete the practising pointer
    @
    void practising::closeEvent(QCloseEvent *event)
    {
    if (qDebugDemo>=2)
    { qDebug()<< "practising::closeEvent";
    qDebug() << "to delete handpop";
    }
    if (!handpop.isNull())
    {
    //emit(this->ToHandWindowDeleteYourSelf());
    handpop.data()->close();
    }
    delete handpop;

    PractiseTimerFire->stop();
    disconnect(PractiseTimerFire,0);
    
    if (qDebugDemo>=2) {qDebug()<<"to delete highlighter";}
    delete highlighter;
    
    if (qDebugDemo>=2) {qDebug() << "to delete keyboard map ";}
    delete kbmap;
    
    if (qDebugDemo>=2) {qDebug() << "to delete timer";}
    delete PractiseTimerFire;
    
    
    
    if (qDebugDemo>=2) {qDebug() << " delete scroll bar";}
    delete sb;
    
    if (qDebugDemo>=2) {qDebug() << " ------------";}
    
    this->done(1);
    emit(this->ToTypingDeletePractise(1));
    if (qDebugDemo>=2) {qDebug() << "practise close me signal emitted";}
    
    
    
    //this->mainparentform->show();
    //event->accept();
    
    qDebug() << "closesevent - first part pass" << handpop.isNull();
    
    
    //delete inst_speed;
    //delete inst_speed_correct;
    //delete inst_speed_correct_diff;
    //delete inst_speed_timepassd;
    
    //Practise_AddToDataBase(); // Add data to dB
    
    //Q_UNUSED(event); //unreferenced formal parameter
    //qDebug() << "closever 3";
    quitpractise = true;
    //delete ui;
    //event->ignore();
    

    }
    @

    in typingmain
    @
    void TypingTutorMain::CloseChild(int childnumber)
    {
    switch (childnumber)
    {
    case 1:
    if (! practiseform.isNull())
    {
    qDebug()<<"signal received delete practise follows";
    practiseform.data()->deleteLater();
    qDebug() << "is practise deleted?"<< practiseform.isNull();
    }
    }
    }
    @

    Note that if i use
    //QScopedPointer<practising> practiseform(new practising(true,1,0,0));
    it which is the same as QPointer but it deletes it self automatic, it crashes, even if i disable emiting the ToTypingDeletePractise signal

    I don't know if i close the handpop correctly

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

      It looks like your are using dialogs and not just widget and you only use them locally. So just don't create pointers to QDialogs if the logic is:

      Create dialog

      Ask something to the user

      Get result

      Delete dialog

      You really should first go through the examples in Qt's documentation. You are starting to write code that is going to be a nightmare to follow and maintain.

      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