Results 1 to 5 of 5

Thread: QSerialDevice enumerator deletion question

  1. #1
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question QSerialDevice enumerator deletion question

    I have a question about SerialDeviceEnumerator. Since it is mentioned here A LOT, I think (hope) I can ask it in this forum.

    The enumerator object gets created automatically using the static instance() method, which creates an instance of the object and remembers this in SerialDeviceEnumerator::self.

    However, when does this object ever gets deleted ? At the end of the program, the destructor for SerialDeviceEnumerator::self will NOT be called because it is just a pointer, not an instance.

    I don't see anything in the enumerator example to delete the instance either.

    Best regards,
    Marc

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSerialDevice enumerator deletion question

    Upon completion of the application, the OS itself will remove all.
    No need to call the destructor.

    PS:
    This version of the library is outdated.
    Instead it use of version 2.0, as it will be included in Qt as a addon.
    Already in progress preparatory work for the integration.

  3. #3
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSerialDevice enumerator deletion question

    Hi,

    I went to http://gitorious.org/qserialdevice and took a copy of the master branch. Isn't this the latest then ?

    In my opinion, it is a rather 'dirty' programming practice to just let the OS clean up all the handles you left open... Especially in a cross-platform environment like Qt where not every OS may behave as expected. Maybe you could consider the Meyers approach for the singleton pattern.

    Regards,
    Marc

  4. #4
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Thanks
    2
    Thanked 43 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSerialDevice enumerator deletion question

    I went to http://gitorious.org/qserialdevice and took a copy of the master branch. Isn't this the latest then ?
    No, master branch is the old library to the old API, as with version 0.3 and 0.4.

    The new branch 2.0 is completely different, has a different API, which is radically different from the old API.
    The difference is in the name, count and functionality of its constituent classes,
    as well as extensive support for new operating systems.

    See simply wiki: http://gitorious.org/qserialdevice/pages/Home
    Direct link to 2.0: http://gitorious.org/qserialdevice/q...vice/trees/2.0

    In my opinion, it is a rather 'dirty' programming practice to just let the OS clean up all the handles you left open... Especially in a cross-platform environment like Qt where not every OS may behave as expected. Maybe you could consider the Meyers approach for the singleton pattern.
    I know it's dirty. But since memory is allocated only once - then the dirt is not so dirty.
    The new library, this class of functional and removed. So do not worry.

  5. #5
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QSerialDevice enumerator deletion question

    Hi kuzulis,

    Is the 2.0 branch fully functional ? I started a very simple 'terminal' like program, and it seems to me that the readyRead() signal is not always emitted.

    I send a text command to a device, and it sends me about 20 lines of text. On the first readyRead(), about 6 lines are in the buffer and I read it all. There is no readyRead() signal for data arriving after this. When I send a new command, readyRead() fires again, and then I see the remaining data.

    I have put a small example program in attachment. Only the com_data_available() and on_leCmd_returnPressed() functions are relevant. The .pro file will need to be adapted to include SerialPort on your computer. I'm using Windows.

    Best regards,
    Marc
    Attached Files Attached Files

Similar Threads

  1. Running the enumerator from QextSerialPort
    By Sherban in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2011, 02:46
  2. question about QSerialDevice (baudrate)
    By mastupristi in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2009, 08:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.