Forum

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 32
  1. #16
    Join Date
    February 2017
    Posts
    45
    It crashes again

    Scenario 1:
    I connect to the server, move around, disconnect, deactivate the plugin

    Scenario 2:
    i connect to the server, don't move around, deactivate the plugin

    Scenario 3:
    I connect to the server, move around, deactivate the plugin

    Only scenario 3 causes a crash. WHY???

    Latest progress can be found here: https://git.rwth-aachen.de/carstenf/...ay/tree/master

  2. #17
    Join Date
    September 2012
    Posts
    6,078
    I'd guess it's got something to do with your cleanup, especially the Timer deleting your lines. It probably fires while things are already being destroyed.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  3. #18
    Join Date
    February 2017
    Posts
    45
    but on my scenario 1-3 there was never a chatline added. And if you look at it carefully, before the timer delete operation is done it checks if this file exist. Qt handles that very good and even if the receiver is deleted it will not crash. The signal is emited and simply no one handles it.

    and btw. this function was implemented before and never caused problems.

    So it needs to be something else.

  4. #19
    Join Date
    September 2012
    Posts
    6,078
    You said it only happens when you move around, which will cause addNewLine to be called https://git.rwth-aachen.de/carstenf/...n.cpp#L401-416
    Which then means there's a timer https://git.rwth-aachen.de/carstenf/...oller.cpp#L129 calling a function on your object that is gone by the time it fires if the plugin is disabled before that happens. In fact the whole DLL file will be unloaded by the time the timer fires in that case.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  5. #20
    Join Date
    February 2017
    Posts
    45
    are you sure you didn't wrote that code?? I'm so blind. I just tested and yeah it crash when the text is already displayed. So Why does it not happen when i disconnect?? It's doing the same: https://git.rwth-aachen.de/carstenf/...lugin.cpp#L351

  6. #21
    Join Date
    September 2012
    Posts
    6,078
    Quote Originally Posted by GT-Anakin View Post
    So Why does it not happen when i disconnect?? It's doing the same: https://git.rwth-aachen.de/carstenf/...lugin.cpp#L351
    It will also crash
    Last edited by Chris; March 3rd, 2017 at 04:24 PM.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  7. #22
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Yes indeed, Qt won't call a slot on a deleted object (in fact, all signal-slot-connections of the object are disconnected on destroy). But, your timer is not connected to your object, but to a lambda. While your object is destroyed, the lambda is not. So simply add a new slot to your controller to call deleteChatLine. Then the Qt magic will work again.

    Edit:
    See this example:

    Code:
    /* testobj.h */
    #ifndef TESTOBJ__H_
    #define TESTOBJ__H_
    
    #include <QObject>
    #include <QTimer>
    #include <QDebug>
    
    class testobj: public QObject {
      Q_OBJECT
    
      public:
        testobj(QObject* parent = 0): QObject(parent) {
          QTimer::singleShot(2000, [=] { qDebug() << "yep, still here!"; });
          deleteLater();
        }
    
        ~testobj() { qDebug() << "I was deleted"; }
    
    };
    
    
    #endif
    
    /* main.cpp */
    #include <QCoreApplication>
    
    #include "testobj.h"
    
    
    int main(int argc, char** argv) {
      QCoreApplication app(argc, argv);
    
      testobj* foo = new testobj();
      /* it will delete itself */
    
      return app.exec();
    }
    
    /* test.pro */
    TEMPLATE = app
    TARGET = test
    DEPENDPATH += .
    INCLUDEPATH += .
    CONFIG += c++11
    QT = core
    
    # Input
    SOURCES += main.cpp
    HEADERS += testobj.h
    Last edited by Thomas; March 3rd, 2017 at 05:38 PM.

  8. #23
    Join Date
    February 2017
    Posts
    45
    i tested disconnect and it does not crash. I understand the Lambda problem. But without Lambda i cannot pass a parameter to the delete function

  9. #24
    Join Date
    May 2016
    Location
    Idar-Oberstein
    Posts
    163
    Iirc QTimer::singleShot(500, this, [this](){});
    should enable the Qt magic.

  10. #25
    Join Date
    September 2012
    Posts
    6,078
    Quote Originally Posted by GT-Anakin View Post
    i tested disconnect and it does not crash. I understand the Lambda problem. But without Lambda i cannot pass a parameter to the delete function
    You don't really need to anyway, as you're always deleting the one that is the last one in the vector where you store them.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  11. #26
    Join Date
    February 2017
    Posts
    45
    @thorwe: the magic came not back -.-

    @Chriss: No i cannot remove the parameter. It works that way:

    Delete message after 5 seconds,
    if there are more then 5 lines, remove the last, no matter if the time is out.

    Removing the parameter results in this:
    if there are more then 5 lines remove the last
    5 seconds after a message is printed, remove the last one.

    Scenario:
    Time0: message 1
    time4: message 2,3,4,5,6 => message 1 deleted at time 4
    time5: timer from message 1 deletes message 2
    time 10: timer from message 2,3,4,5,6 delete message 3,4,5,6 and EMTPY => crash

  12. #27
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Adding a QTimer attribute to your controller could be a workaround.

    Edit: But thorwe is right, adding your controller as context should work (https://doc.qt.io/qt-5/qtimer.html#singleShot-6). At least it works here.
    Last edited by Thomas; March 3rd, 2017 at 06:48 PM.

  13. #28
    Join Date
    September 2012
    Posts
    6,078
    Ah well yeah true you'd end up deleting faster than anticipated if you overfill before the time runs out. Didn't think about that.
    You could just create the timer object as a child of the widget instead of using the static convenience function and then pretty much keep doing what you're doing.
    When sending PMs please make sure to include a reference link to the thread in question in the body of your message.

  14. #29
    Join Date
    February 2017
    Posts
    45
    i don't know why the context does not work. But using an actual instance of QTimer instead of a static call did the magic:
    https://git.rwth-aachen.de/carstenf/...oller.cpp#L131

    And the delete line will delete unused timer again https://git.rwth-aachen.de/carstenf/...roller.cpp#L72

    So even if you use this plugin 24 hours and there are millions of chatlines there won't be millions of unused QTimer in the memory.

    Thanks to all how helped me with that problem!!

  15. #30
    Join Date
    February 2017
    Posts
    45
    This is driving me crazy

    https://git.rwth-aachen.de/carstenf/...073b80cb6f7e88

    I sort my channels in the correct order and it worked.

    So i thought it's not a good idea to clear the whole tree if only a client moved. So i split it off into two parts:
    1) remove all channels, get all current channels and put them in the tree
    2) remove all clients, get all current clients and put them in the tree

    But that crashes again. First it crashed even before i entered. Then i removed the updateChannel calls in the callback functions and i was able to connect again. Moving around,... all was fine
    But on disconnect it crashed again. I put some BEEP in the code and found out that even this line was never touched https://git.rwth-aachen.de/carstenf/...lugin.cpp#L351

    I looked so much on that code i see no matter for a crash. I hope you do.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 24h disconnect
    By tuvok1981 in forum Windows
    Replies: 17
    Last Post: January 27th, 2013, 02:02 PM
  2. Disconnect
    By Samonq in forum Client Support
    Replies: 0
    Last Post: January 1st, 2011, 01:15 PM
  3. Always disconnect
    By thunderstorm99 in forum Windows
    Replies: 0
    Last Post: August 1st, 2010, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •