You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male
  • "AP.Sakkthivel" started this thread

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

1

Friday, August 5th 2005, 11:11am

QMutex in Qt4

This is the statement i am using to initialize the static mutex
QMutex Thread::Mutex = QMutex();
in Qt 3;

what could be its peer in Qt4;

since the above statement is not compiled when i use Qt4 GPL for win with minGW

any guess

Thanx in Advance
Regards
- $akthi

You never know, how soon it may be too late…

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

2

Friday, August 5th 2005, 11:14am

RE: QMutex in Qt4

Quoted

Originally posted by AP.Sakkthivel
since the above statement is not compiled when i use Qt4 GPL for win with minGW

Could you post the exact error message?

AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male
  • "AP.Sakkthivel" started this thread

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

3

Friday, August 5th 2005, 11:21am

RE: QMutex in Qt4

C:/Qt/4.0.0/include/QtCore/../../src/corelib/thread/qmutex.h:63: error: `QMutex:
:QMutex(const QMutex&)' is private
Thread.cpp:95: error: within this context
C:/Qt/4.0.0/include/QtCore/../../src/corelib/thread/qmutex.h:63: error: `QMutex:
:QMutex(const QMutex&)' is private
Regards
- $akthi

You never know, how soon it may be too late…

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

4

Friday, August 5th 2005, 11:22am

RE: QMutex in Qt4

Then try this:

Source code

1
QMutex Thread::Mutex;

AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male
  • "AP.Sakkthivel" started this thread

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

5

Friday, August 5th 2005, 11:25am

RE: QMutex in Qt4

Yha Jacek

I did the same exactly but my question is
cant we use Constuctor for initializing

Thanx to reply

cheers
Regards
- $akthi

You never know, how soon it may be too late…

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

6

Friday, August 5th 2005, 11:37am

RE: QMutex in Qt4

Quoted

Originally posted by AP.Sakkthivel
I did the same exactly but my question is
cant we use Constuctor for initializing

A construtor is always executed.

In this code:

Source code

1
QMutex Thread::Mutex = QMutex();
you create an anonymous, temporary object and assign it (using the copy constructor) to your static variable. It's equivalent to:

Source code

1
QMutex Thread::Mutex(QMutex());
It doesn't work, because the copy constructor is private --- how should a copy of a mutex behave?

AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male
  • "AP.Sakkthivel" started this thread

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

7

Friday, August 5th 2005, 11:52am

RE: QMutex in Qt4

I am NOT clear with you

but the same code worked in Qt3 version without any problem

can you say why?

Thanks for reply
Regards
- $akthi

You never know, how soon it may be too late…

This post has been edited 1 times, last edit by "AP.Sakkthivel" (Aug 5th 2005, 11:53am)


jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

8

Friday, August 5th 2005, 12:04pm

RE: QMutex in Qt4

Quoted

Originally posted by AP.Sakkthivel
can you say why?

Either you didn't have Q_DISABLE_COPY macro defined in Qt3 or you were using different compiler, that optimized your code and threw away that unnecessary temporary object.

This post has been edited 1 times, last edit by "jacek" (Aug 5th 2005, 12:04pm)