C++ (Cpp) Q_ASSERT Examples

C++ (Cpp) Q_ASSERT - 30 examples found. These are the top rated real world C++ (Cpp) examples of Q_ASSERT extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
//............................................................................
void QActive::start(uint_t prio,
                    QEvt const *qSto[], uint_t qLen,
                    void *stkSto, uint_t stkSize,
                    QEvt const *ie)
{
    m_eQueue = OSQCreate((void **)qSto, qLen);
    Q_ASSERT(m_eQueue != (OS_EVENT *)0);             // uC/OS-II queue created
    m_prio = static_cast<uint8_t>(prio);     // set the QF priority of this AO
    QF::add_(this);                                // make QF aware of this AO

    this->init(ie);               // execute initial transition (virtual call)
    QS_FLUSH();                          // flush the trace buffer to the host

    uint8_t p_ucos = QF_MAX_ACTIVE - m_prio;    // map QF priority to uC/OS-II
    INT8U err = OSTaskCreateExt(&task_function,           // the task function
                                this,                                    // the 'pdata' parameter
                                &(((OS_STK *)stkSto)[(stkSize / sizeof(OS_STK)) - 1]),    // ptos
                                p_ucos,                                 // uC/OS-II task priority
                                p_ucos,             // the unique priority is the task id as well
                                (OS_STK *)stkSto,                                         // pbos
                                stkSize/sizeof(OS_STK),      // size of the stack in OS_STK units
                                (void *)0,                                                // pext
                                (INT16U)OS_TASK_OPT_STK_CLR);                              // opt
    Q_ASSERT(err == OS_NO_ERR);                       // uC/OS-II task created
    m_thread = 1U;             // to keep the active object task loop spinning
}
Example #2
0
QModelIndex FlatProxyModel::mapToSource(const QModelIndex &proxyIndex) const
{
    if (!proxyIndex.isValid())
        return QModelIndex();

    Q_ASSERT(proxyIndex.model() == this);
    Q_ASSERT(_rootSourceItem);

    int row = proxyIndex.row();
    QModelIndex sourceParent;
    SourceItem *sourceItem = _rootSourceItem->findChild(row);
    while (sourceItem) {
        if (sourceItem->pos() == row) {
            return sourceModel()->index(sourceItem->sourceRow(), proxyIndex.column(), sourceParent);
        }
        else {
            sourceParent = sourceModel()->index(sourceItem->sourceRow(), 0, sourceParent);
            sourceItem = sourceItem->findChild(row);
        }
    }

    qWarning() << "FlatProxyModel::mapToSource(): couldn't find source index for" << proxyIndex;
    Q_ASSERT(false);
    return QModelIndex(); // make compilers happy :)
}
//! [0]
IconPreviewArea::IconPreviewArea(QWidget *parent)
    : QWidget(parent)
{
    QGridLayout *mainLayout = new QGridLayout;
    setLayout(mainLayout);

    stateLabels[0] = createHeaderLabel(tr("Off"));
    stateLabels[1] = createHeaderLabel(tr("On"));
    Q_ASSERT(NumStates == 2);

    modeLabels[0] = createHeaderLabel(tr("Normal"));
    modeLabels[1] = createHeaderLabel(tr("Active"));
    modeLabels[2] = createHeaderLabel(tr("Disabled"));
    modeLabels[3] = createHeaderLabel(tr("Selected"));
    Q_ASSERT(NumModes == 4);

    for (int j = 0; j < NumStates; ++j)
        mainLayout->addWidget(stateLabels[j], j + 1, 0);

    for (int i = 0; i < NumModes; ++i) {
        mainLayout->addWidget(modeLabels[i], 0, i + 1);

        for (int j = 0; j < NumStates; ++j) {
            pixmapLabels[i][j] = createPixmapLabel();
            mainLayout->addWidget(pixmapLabels[i][j], j + 1, i + 1);
        }
    }
}
Example #4
0
static QScriptValue qtscript_QFormLayout_static_call(QScriptContext *context, QScriptEngine *)
{
    uint _id = context->callee().data().toUInt32();
    Q_ASSERT((_id & 0xFFFF0000) == 0xBABE0000);
    _id &= 0x0000FFFF;
    switch (_id) {
    case 0:
        if (context->thisObject().strictlyEquals(context->engine()->globalObject())) {
            return context->throwError(QString::fromLatin1("QFormLayout(): Did you forget to construct with 'new'?"));
        }
        if (context->argumentCount() == 0) {
            QtScriptShell_QFormLayout* _q_cpp_result = new QtScriptShell_QFormLayout();
            QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QFormLayout*)_q_cpp_result, QScriptEngine::AutoOwnership);
            _q_cpp_result->__qtscript_self = _q_result;
            return _q_result;
        } else if (context->argumentCount() == 1) {
            QWidget* _q_arg0 = qscriptvalue_cast<QWidget*>(context->argument(0));
            QtScriptShell_QFormLayout* _q_cpp_result = new QtScriptShell_QFormLayout(_q_arg0);
            QScriptValue _q_result = context->engine()->newQObject(context->thisObject(), (QFormLayout*)_q_cpp_result, QScriptEngine::AutoOwnership);
            _q_cpp_result->__qtscript_self = _q_result;
            return _q_result;
        }
        break;

    default:
        Q_ASSERT(false);
    }
    return qtscript_QFormLayout_throw_ambiguity_error_helper(context,
            qtscript_QFormLayout_function_names[_id],
            qtscript_QFormLayout_function_signatures[_id]);
}
Example #5
0
bool QToolBarAreaLayout::insertGap(const QList<int> &path, QLayoutItem *item)
{
    Q_ASSERT(path.count() == 3);
    const int i = path.first();
    Q_ASSERT(i >= 0 && i < QInternal::DockCount);
    return docks[i].insertGap(path.mid(1), item);
}
void KreenGraphicsItemBase::configurePen(QGraphicsLineItem* grItem)
{
    // items that want to configure these properties will have them otherwise it is programming error (prototype pattern)
    Q_ASSERT(_item->lineColor());
    Q_ASSERT(_item->lineStyle());
    grItem->setPen(QPen(_item->lineColor()->color, _item->lineStyle()->width, _item->lineStyle()->penStyle, Qt::RoundCap, Qt::RoundJoin));
}