pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


quantron libvt use QMutexLocker patch
Posted by Anonymous on Thu 17th Jan 2019 12:51
raw | new post

  1. diff --git a/ptxdist/local_src/libvt/ECom/ecbinterface.cpp b/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  2. index cd3fd19..550eb3f 100644
  3. --- a/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  4. +++ b/ptxdist/local_src/libvt/ECom/ecbinterface.cpp
  5. @@ -32,6 +32,7 @@
  6.  
  7.  #include <QByteArray>
  8.  #include <QMutex>
  9. +#include <QMutexLocker>
  10.  #include <QTime>
  11.  #include <QReadWriteLock>
  12.  #include <QFlags>
  13. @@ -116,12 +117,14 @@ char* _pReadBuffer=_RxBuffer.data();
  14.  char* _pWriteBuffer=_RxBuffer.data();
  15.  char* _pEndBuffer=(_RxBuffer.data() + RXBUFFER_SIZE_E);
  16.  bool _full(false);
  17. -QMutex __Lock;
  18. +
  19. +static QMutex __Lock;
  20.  
  21.  int data_in( char* data, int size){
  22.     int iRet(-1);
  23.  
  24. -   __Lock.lock();  
  25. +   QMutexLocker mylocker(&__Lock);
  26. +
  27.     if ( _full == true ) {
  28.        // Spezielles Event versenden an GUI-Thread, damit Buffer abgearbeitet wird/gelöscht wird.
  29.        postECbEvent( ECB_FULLEVENT_E );
  30. @@ -173,7 +176,7 @@ int data_in( char* data, int size){
  31.           _full = true;
  32.        }
  33.     }
  34. -   __Lock.unlock();
  35. +   mylocker.unlock();
  36.  
  37.     if ( iRet == size ) {
  38.        // Spezielles Event versenden an GUI-Thread, damit Buffer abgearbeitet wird.
  39. @@ -192,7 +195,7 @@ int data_check(void){
  40.     WORD_UI length;
  41.  
  42.     length.word = -1;
  43. -   __Lock.lock();
  44. +   QMutexLocker mylocker(&__Lock);
  45.  
  46.  
  47.     if ( ( _pReadBuffer != _pWriteBuffer ) || (_full == true) ) {
  48. @@ -228,21 +231,18 @@ int data_check(void){
  49.     else {
  50.        length.word = 0;
  51.     }
  52. -   __Lock.unlock();
  53.  
  54.     return length.word;
  55.  }
  56.  
  57.  void data_clear(void){
  58. -   __Lock.lock();
  59. +   QMutexLocker mylocker(&__Lock);
  60.  
  61.     // Variablen/Buffer zurücksetzen
  62.     _pReadBuffer=_RxBuffer.data();
  63.     _pWriteBuffer=_RxBuffer.data();
  64.     _pEndBuffer=(_RxBuffer.data() + RXBUFFER_SIZE_E);
  65.     _full = false;
  66. -
  67. -   __Lock.unlock();
  68.  }
  69.  
  70.  int data_out( char* data, int size){
  71. @@ -250,7 +250,7 @@ int data_out( char* data, int size){
  72.     WORD_UI length;
  73.     int iRet = 0;
  74.  
  75. -   __Lock.lock();
  76. +   QMutexLocker mylocker(&__Lock);
  77.     length.word = -1;
  78.  
  79.     if ( (_pReadBuffer != _pWriteBuffer) || (_full==true) ) {
  80. @@ -304,7 +304,7 @@ int data_out( char* data, int size){
  81.           _pReadBuffer = _RxBuffer.data();
  82.        }
  83.     }
  84. -   __Lock.unlock();
  85. +   mylocker.unlock();
  86.  
  87.     if ( (iRet < 0) || (iRet != size) ) {
  88.        // Beim Schreiben kam es zu einem Fehler

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at