[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KDE, Qt3 and Amarok
From:       "Bart Van Assche" <bart.vanassche () gmail ! com>
Date:       2008-04-20 10:30:11
Message-ID: e2e108260804200330m4e80acdep7ec146b53212442b () mail ! gmail ! com
[Download RAW message or body]

On Sat, Apr 19, 2008 at 5:29 PM, Thiago Macieira <thiago@kde.org> wrote:
> But I have to tell you: this is a bug in Amarok, not in Qt. They should be
> making deep copies of all objects that will be used in a different
> thread.

I'm neither a Qt nor a KDE expert. Can you please have a look at the
program below and tell me whether or not the programming style is
acceptable ? The program below triggers several data races with Qt3,
but does not trigger any data races with Qt4.

Bart.

-----------------------------------------------------------------------------------------------------------------------------
 #include <pthread.h>
#if defined(QT3)
#include <qstring.h>
#else
#include <Qt/qstring.h>
#endif

void* thread_func(void* arg)
{
  const QString* pS1 = reinterpret_cast<QString*>(arg);
  QString S2 = *pS1;
  S2 = "def";
  return 0;
}

int main(void)
{
  pthread_t tid1;
  pthread_t tid2;
  QString S1 = "abc";
  pthread_create(&tid1, 0, thread_func, &S1);
  pthread_create(&tid2, 0, thread_func, &S1);
  pthread_join(tid1, 0);
  pthread_join(tid2, 0);
  return 0;
}

// Local variables:
// compile-command: "g++ -g -Wall -Wextra -Werror -DQT3
-I/usr/lib/qt3/include -L/usr/lib/qt3/lib64 -o qt3-string
qt-string.cpp -lqt-mt && g++ -g -Wall -Wextra -Werror -DQT4 -o
qt4-string qt-string.cpp -lQtCore"
// End:
-----------------------------------------------------------------------------------------------------------------------------
  
> > Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic