On Wed, 12 Oct 2005, Jeremy C. Reed wrote:
> On Wed, 21 Sep 2005, Angus Leeming wrote:
>
>> Anyway, trying to unlock a mutex that is already unlocked will
>> result in undefined behaviour when using POSIX threads. See, for
>> example Section 3.3.2 "Locking and unlocking a mutex" of
>> "Programming with POSIX threads" by David R Butenhof.
>>
>> So, I'm not going to apply your fix; sorry.
>
> I was also told in
> http://thread.gmane.org/gmane.editors.lyx.devel/46629 that "The
> problem is that QApplication::locked() is lying to you. That's a Qt
> problem, so the solution must be: fix Qt on NetBSD."
>
> So I filed a bug report with trolltech. They gave me some sample
> code to run and I did several tests. This was their reply:
>
> Right. You are sure that it's the destruction of the QApplication
> mutex that's causing this? Anyway, I'm not sure I see the reason
> why they're trying to unlock the QApplication mutex, you're
> supposed to lock it from other threads than the thread where
> QApplication was created, and you're not allowed to unlock a mutex
> from a thread that did not previously lock it. I also noticed the
> following paragraph from the QMutex::locked() documentation that
> could be related:
>
> Warning: Due to different implementations of recursive mutexes on
> the supported platforms, calling this function from the same thread
> that previously locked the mutex will give undefined results.
>
> Does this help at all?
Jeremy, you're absolutely right. We're attempting to fix one bug by
introducing another.
Jean-Marc, let's go back to the old behaviour ("Mutex destroy failure:
Device or resource busy" on exit on some machines but not others) as
the 'fix':
http://lists.trolltech.com/qt-interest/2003-01/thread00009-0.html
is no fix at all.
I suggest we apply this to 1.3.x as well.
--
Angus
Index: src/frontends/qt2/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.86
diff -u -p -r1.86 lyx_gui.C
--- src/frontends/qt2/lyx_gui.C 16 Jul 2005 15:55:35 -0000 1.86
+++ src/frontends/qt2/lyx_gui.C 14 Oct 2005 16:10:28 -0000
@@ -135,12 +135,7 @@ LQApplication::LQApplication(int & argc,
LQApplication::~LQApplication()
-{
-#ifdef QT_THREAD_SUPPORT
- if (locked())
- unlock();
-#endif
-}
+{}
#ifdef Q_WS_MACX