Potential problem wint 1.2.0 under Windows

28 views
Skip to first unread message

RFOG RANO

unread,
Jul 12, 2012, 2:54:48 PM7/12/12
to qextser...@googlegroups.com
Hi all!

If developer does not closes serial port and let system to close itself when destructing the port object, there is a problem with the code. 

I will try to explain. 

In  qexteventnotifier_p.cpp, QextWinEventNotifier::setEnabled() method uses a global notiifier thread called by notifierThread(), created by a QT macro:

Q_GLOBAL_STATIC(QextWinEventNotifierThread, notifierThread)

It seems QT deletes that thread *before* serial port is closed and deleted. Then, the last call to setEnabled(false) deals in notifierThread() returning 0 as address. After that you will get an OS exception.

My solutions is to add this:

void QextWinEventNotifier::setEnabled(bool enable)

{

    Q_D(QextWinEventNotifier);


    if (d->enabled == enable)

        return;

    d->enabled = enable;


//RFOG PATCH: at this level if dtor chain call with serial port open, notifierThread has been deleted by QT

if(notifierThread()==0)

return;


    if (d->enabled)

        notifierThread()->registerEventNotifier(this);

    else

        notifierThread()->unregisterEventNotifier(this);

}


Of course, code works fin if user calls to close() before destructors chains get launched. BTW, I've solved my code avoiding call close() in my own destructors but I've maintained that code in setEnabled() method in my code. 

Reply all
Reply to author
Forward
0 new messages