Ticket #47496: patch-no-concurrent-meinproc4.diff

File patch-no-concurrent-meinproc4.diff, 1.8 KB (added by RJVB (René Bertin), 10 years ago)
  • kdoctools/meinproc.cpp

    diff --git a/kdoctools/meinproc.cpp b/kdoctools/meinproc.cpp
    index 9a5b715..32be62f 100644
    a b  
    1616#include <kcomponentdata.h>
    1717#include <kcmdlineargs.h>
    1818#include <kdebug.h>
     19#undef QT_NO_DEBUG_OUTPUT
    1920#include <klocale.h>
    2021#include <kstandarddirs.h>
    2122#include <kshell.h>
    2223#include <kurl.h>
     24#include <klockfile.h>
    2325
    2426#include <libxml/xmlversion.h>
    2527#include <libxml/xmlmemory.h>
    int main(int argc, char **argv) { 
    125127    LIBXML_TEST_VERSION
    126128
    127129    const QString checkFilename = args->arg( 0 );
     130#ifdef Q_OS_MAC
     131    // prevent potential issues due to concurrent execution
     132    const QString checkLockFileName = QLatin1String("meinproc4.lock");
     133    KLockFile checkLock = KLockFile(checkLockFileName);
     134    // give any "competitors" a bit more time than the default before we become impatient
     135    checkLock.setStaleTime(60);
     136#endif
    128137    CheckFileResult ckr = checkFile( checkFilename );
    129138    if ( ckr != CheckFileSuccess )
    130139    {
    int main(int argc, char **argv) { 
    188197    const bool usingOutput = args->isSet("output");
    189198    const QString outputOption = args->getOption( "output" );
    190199
     200#ifdef Q_OS_MAC
     201    if (checkLock.isLocked()) {
     202        qDebug() << "Waiting to get a lock on" << checkLockFileName;
     203        KLockFile::LockResult locked = checkLock.lock(KLockFile::ForceFlag);
     204        qDebug() << "lock result=" << locked;
     205    }
     206    else {
     207        KLockFile::LockResult locked = checkLock.lock(KLockFile::ForceFlag);
     208        if (locked != KLockFile::LockOK) {
     209            qWarning() << "Error locking" << checkLockFileName << "which was not yet locked";
     210        }
     211    }
     212#endif
     213
    191214    if ( index ) {
    192215        xsltStylesheetPtr style_sheet =
    193216            xsltParseStylesheetFile((const xmlChar *)tss.toLatin1().data());