コード例 #1
0
ファイル: qsinterpreter.cpp プロジェクト: gestiweb/eneboo
/*!
  \internal
*/
void QSInterpreter::runtimeError(const QString &message,
                                 const QString &scriptName,
                                 int lineNumber)
{
#ifdef QSDEBUGGER
  emit error(message, scriptName, lineNumber);
  QObject *ctx = d->interpreter->objectOfSourceId(d->interpreter->debuggerEngine()->sourceId());

  emit error(message, ctx, scriptName, lineNumber);

  if (errorMode() == Notify) {
    if (qApp->type() == QApplication::Tty
#if defined (QT_THREAD_SUPPORT) && QT_VERSION >= 0x030300
        || qt_get_application_thread_id() != QThread::currentThread()
#endif
       ) {
      qDebug("Error in script: '%s', line: %d\n  %s\n",
             scriptName.latin1(), lineNumber, message.latin1());
    } else {
      QMessageBox::critical(qApp->mainWidget(), QString::fromLatin1("Error"),
                            QString::fromLatin1("The following error occurred in "
                                                "line <b>%1</b> of  <b>%2</b> while executing "
                                                "the script:<pre><font color=red>%3</font></pre>")
                            .arg(lineNumber).arg(scriptName).arg(message));
    }
  } else if (errorMode() == AskForDebug) {
    // TODO: Add here code to debug the runtimeError...
    qDebug("Error in script: '%s', line: %d\n  %s\n",
           scriptName.latin1(), lineNumber, message.latin1());
  }
#else
  QMessageBox::critical(qApp->mainWidget(), QString::fromLatin1("Error"),
                        QString::fromLatin1("The following error occurred in "
                                            "line <b>%1</b> of  <b>%2</b> while executing "
                                            "the script:<pre><font color=red>%3</font></pre>")
                        .arg(lineNumber).arg(scriptName).arg(message));
#endif
}
コード例 #2
0
ファイル: oodRoutines.cpp プロジェクト: ooRexx/ooRexx
static char *searchSoundPath(CSTRING file, RexxCallContext *c)
{
    oodResetSysErrCode(c->threadContext);

    // We need a buffer for the path to search, a buffer for the returned full
    // file name, (if found,) and a pointer to char (an unused arg to
    // SearchPath().)
    char *fullFileName = NULL;
    char *pFileName;

    // Calculate how much room we need for the search path buffer.
    uint32_t cchCWD = GetCurrentDirectory(0, NULL);

    // Many modern systems no longer have the SOUNDPATH set.
    SetLastError(0);
    uint32_t cchSoundPath = GetEnvironmentVariable("SOUNDPATH", NULL, 0);
    uint32_t rc = GetLastError();
    if ( cchSoundPath == 0 && rc != ERROR_ENVVAR_NOT_FOUND )
    {
        oodSetSysErrCode(c->threadContext, rc);
        return NULL;
    }

    // Allocate our needed buffers.
    AutoFree buf = (char *)malloc(cchCWD + cchSoundPath + 3);
    fullFileName = (char *)malloc(_MAX_PATH);
    if (buf == NULL || fullFileName == NULL)
    {
        safeFree(fullFileName);
        outOfMemoryException(c->threadContext);
    }

    // Now get the current directory and the sound path.
    cchCWD = GetCurrentDirectory(cchCWD + 1, buf);
    if (cchCWD == 0)
    {
        safeFree(fullFileName);
        oodSetSysErrCode(c->threadContext);
        return NULL;
    }

    if (cchSoundPath != 0)
    {
        buf[cchCWD++] = ';';
        cchSoundPath = GetEnvironmentVariable("SOUNDPATH", buf + cchCWD, cchSoundPath + 1);
        if (cchSoundPath == 0)
        {
            safeFree(fullFileName);
            oodSetSysErrCode(c->threadContext);
            return NULL;
        }
    }

    AutoErrorMode errorMode(SEM_FAILCRITICALERRORS);
    cchSoundPath = SearchPath(buf, file, NULL, _MAX_PATH, fullFileName, &pFileName);

    if (cchSoundPath == 0 || cchSoundPath >= _MAX_PATH)
    {
        safeFree(fullFileName);
        oodSetSysErrCode(c->threadContext);
        return NULL;
    }

    return fullFileName;
}