Example #1
0
GLVDetachable& GLVDetachable::detached(bool v){
	if(v && !detached()){			// is not detached
		if(mParentWindow){
			remGUI(parentWindow());
		}
		glv::Rect ru = unionOfChildren();
		enable(glv::DrawBack);
		{
			glv::View * cv = child;
			while(cv){
				cv->posAdd(-ru.l, -ru.t);
				cv = cv->sibling;
			}
		}
		//ru.print();
		//posAdd(-ru.l, -ru.t);
		detachedWindow().create(Window::Dim(ru.w, ru.h));
		addGUI(detachedWindow());
	}
	else if(detached()){			// is currently detached, attach back to parent, if any
		remGUI(detachedWindow());
		detachedWindow().destroy();
		if(mParentWindow){
			disable(glv::DrawBack);
			pos(0,0);
			addGUI(parentWindow());
		}
	}
	return *this;
}
Example #2
0
File: ici.cpp Project: cor3ntin/Ici
QVariant value(const QStringList & keys, const QVariantMap & context,
               const QVariant & defaultValue = QVariant()){
    const QVariantMap* map = &context;
    int i = 0;
    while(i < keys.size()) {
        const QString & key = keys.at(i++);
        QVariantMap::const_iterator it = map->find(key);
        if(it == map->constEnd())
            return defaultValue;
        const QVariant & value = *it;
        if(i >= keys.size()) {
            return detached(value);
        }
        if(value.type() == QVariant::Map)
            map = &asMap(value);
        else if(i == keys.size() -1 && value.type() == QVariant::List) {
            const QString & idxStr = keys.at(i);
            bool ok;
            int idx = idxStr.toInt(&ok);
            if(ok) {
                const QVariantList & lst = asList(value);
                if(idx < lst.size())
                    return detached(lst[idx]);
            }
        }
        else
            return defaultValue;
    }
    return defaultValue;
}
Example #3
0
void manager::detach(execution_unit*, bool invoke_disconnect_message) {
  CAF_LOG_TRACE(CAF_ARG(invoke_disconnect_message));
  // This function gets called from the multiplexer when an error occurs or
  // from the broker when closing this manager. In both cases, we need to make
  // sure this manager does not receive further socket events.
  remove_from_loop();
  // Disconnect from the broker if not already detached.
  if (!detached()) {
    CAF_LOG_DEBUG("disconnect servant from broker");
    auto raw_ptr = parent();
    // Keep a strong reference to our parent until we go out of scope.
    strong_actor_ptr ptr;
    ptr.swap(parent_);
    detach_from(raw_ptr);
    if (invoke_disconnect_message) {
      auto mptr = make_mailbox_element(nullptr, invalid_message_id,
                                       {}, detach_message());
      switch (raw_ptr->consume(*mptr)) {
        case im_success:
          raw_ptr->finalize();
          break;
        case im_skipped:
          raw_ptr->push_to_cache(std::move(mptr));
          break;
        case im_dropped:
          CAF_LOG_INFO("broker dropped disconnect message");
          break;
      }
    }
  }
}
Example #4
0
void zmq::session_base_t::process_attach (i_engine *engine_)
{
    //  If some other object (e.g. init) notifies us that the connection failed
    //  without creating an engine we need to start the reconnection process.
    if (!engine_) {
        zmq_assert (!engine);
        detached ();
        return;
    }

    //  Create the pipe if it does not exist yet.
    if (!pipe && !is_terminating ()) {
        object_t *parents [2] = {this, socket};
        pipe_t *pipes [2] = {NULL, NULL};
        int hwms [2] = {options.rcvhwm, options.sndhwm};
        bool delays [2] = {options.delay_on_close, options.delay_on_disconnect};
        int rc = pipepair (parents, pipes, hwms, delays);
        errno_assert (rc == 0);

        //  Plug the local end of the pipe.
        pipes [0]->set_event_sink (this);

        //  Remember the local end of the pipe.
        zmq_assert (!pipe);
        pipe = pipes [0];

        //  Ask socket to plug into the remote end of the pipe.
        send_bind (socket, pipes [1]);
    }

    //  Plug in the engine.
    zmq_assert (!engine);
    engine = engine_;
    engine->plug (io_thread, this);
}
Example #5
0
SessionItem::SessionItem():
m_session(new Session),
m_active(false),
m_continuous(false),
m_sample_rate(0),
m_sample_count(0)
{
    connect(this, &SessionItem::progress, this, &SessionItem::onProgress, Qt::QueuedConnection);
    connect(this, &SessionItem::finished, this, &SessionItem::onFinished, Qt::QueuedConnection);
    connect(this, &SessionItem::attached, this, &SessionItem::onAttached, Qt::QueuedConnection);
    connect(this, &SessionItem::detached, this, &SessionItem::onDetached, Qt::QueuedConnection);

    m_session->m_completion_callback = [this](unsigned status){
        emit finished(status);
    };

    m_session->m_progress_callback = [this](sample_t n) {
        emit progress(n);
    };
    m_session->m_hotplug_attach_callback = [this](Device* device){
        emit attached(device);
    };
    m_session->m_hotplug_detach_callback = [this](Device* device){
        emit detached(device);
    };
}
void
Event::release() {
  assert(detached());
  assert(m_next_event == 0);
  assert(m_prev_event == 0);
  assert(m_cycle == 0);
}
Example #7
0
void zmq::session_t::detach ()
{
    //  Engine is dead. Let's forget about it.
    engine = NULL;

    detached ();
}
Example #8
0
void MainWindow::removeTrack( TrackItem *track )
{
    m_bModified = true;

    ui->statusBar->showMessage( "Removed track '" + track->pTrackModel->sName + "'", 2500 );
    qDebug() << "Removing track" << track->pTrackModel->sName;

    // Remove and clean up child clips
    for ( int i = 0; i < track->childItems().size(); i++ )
    {
        QGraphicsItem* item = track->childItems()[i];
        m_pScene->removeItem( item );

        ClipItem* clipItem = dynamic_cast<ClipItem*>(item);

        if ( clipItem && m_pClipItems.contains(clipItem) )
        {
            disconnect( clipItem, SIGNAL( mouseDown(ClipItem*) ),   0, 0 );
            disconnect( clipItem, SIGNAL( mouseUp(ClipItem*) ),     0, 0 );
            disconnect( clipItem, SIGNAL( mouseDouble(ClipItem*) ), 0, 0 );
            disconnect( clipItem, SIGNAL( resized(ClipItem*) ),     0, 0 );
            disconnect( clipItem, SIGNAL( detached() ),             0, 0 );

            m_pClipItems.removeAt(m_pClipItems.indexOf(clipItem));
        }
    }
Clip::Playback *Float::getPlayback() const {
	if (detached()) {
		return nullptr;
	}
	if (const auto controller = _controller->roundVideo(_item)) {
		return controller->playback();
	}
	return nullptr;
}
Example #10
0
void zmq::session_t::process_attach (i_engine *engine_,
    const blob_t &peer_identity_)
{
    //  If we are already terminating, we destroy the engine straight away.
    //  Note that we don't have to unplug it before deleting as it's not
    //  yet plugged to the session.
    if (state == terminating) {
        if (engine_)
            delete engine_;
        return;
    }

    //  If some other object (e.g. init) notifies us that the connection failed
    //  without creating an engine we need to start the reconnection process.
    if (!engine_) {
        zmq_assert (!engine);
        detached ();
        return;
    }

    //  Trigger the notfication event about the attachment.
    if (!attached (peer_identity_)) {
        delete engine_;
        return;
    }

    //  Check whether the required pipes already exist. If not so, we'll
    //  create them and bind them to the socket object.
    if (!pipes_attached) {
        zmq_assert (!in_pipe && !out_pipe);
        pipes_attached = true;
        reader_t *socket_reader = NULL;
        writer_t *socket_writer = NULL;

        //  Create the pipes, as required.
        if (options.requires_in) {
            create_pipe (socket, this, options.hwm, options.swap,
                &socket_reader, &out_pipe);
            out_pipe->set_event_sink (this);
        }
        if (options.requires_out) {
            create_pipe (this, socket, options.hwm, options.swap, &in_pipe,
                &socket_writer);
            in_pipe->set_event_sink (this);
        }

        //  Bind the pipes to the socket object.
        if (socket_reader || socket_writer)
            send_bind (socket, socket_reader, socket_writer, peer_identity_);
    }

    //  Plug in the engine.
    zmq_assert (!engine);
    engine = engine_;
    engine->plug (io_thread, this);
}
Example #11
0
void scribe::data_transferred(execution_unit* ctx, size_t written,
                              size_t remaining) {
  CAF_LOG_TRACE(CAF_ARG(written) << CAF_ARG(remaining));
  if (detached())
    return;
  data_transferred_msg tmp{hdl(), written, remaining};
  auto ptr = make_mailbox_element(nullptr, invalid_message_id, {}, tmp);
  parent()->context(ctx);
  parent()->consume(std::move(ptr));
}
Example #12
0
		drawer_trigger* drawer::detached()
		{
			if(realizer_)
			{
				auto rmp = realizer_;
				realizer_ = nullptr;
				rmp->detached();
				return rmp;
			}
			return nullptr;
		}
Example #13
0
		drawer_trigger* drawer::detached()
		{
			if (data_impl_->realizer)
			{
				auto rmp = data_impl_->realizer;
				data_impl_->realizer = nullptr;
				rmp->detached();
				return rmp;
			}
			return nullptr;
		}
Example #14
0
	shared_ptr<Entity> Entity::detachChildEntity(const InstanceID entityID) {
		EntityMapItor foundEntity = mChildren.find(entityID);
		if(foundEntity != mChildren.end()) {
			shared_ptr<Entity> detached(foundEntity->second);
			if(detached) {
				detached->setParent(shared_ptr<Entity>());
			}
			mChildren.erase(foundEntity);
			return detached;
		}
		return shared_ptr<Entity>();
	}
Example #15
0
void manager::detach(bool invoke_disconnect_message) {
  BOOST_ACTOR_LOG_TRACE("");
  if (! detached()) {
    BOOST_ACTOR_LOG_DEBUG("disconnect servant from broker");
    detach_from_parent();
    if (invoke_disconnect_message) {
      auto msg = detach_message();
      parent_->invoke_message(parent_->address(),invalid_message_id, msg);
    }
    parent_ = nullptr;
  }
}
Clip::Reader *Float::getReader() const {
	if (detached()) {
		return nullptr;
	}
	if (const auto controller = _controller->roundVideo(_item)) {
		if (const auto reader = controller->reader()) {
			if (reader->started()) {
				return reader;
			}
		}
	}
	return nullptr;
}
NodeImpl *NodeIteratorImpl::nextNode(int &exceptioncode)
{
    if (detached()) {
        exceptioncode = DOMException::INVALID_STATE_ERR;
        return 0;
    }

    NodeImpl *node = referenceNode() ? referenceNode() : root();
    if (!pointerBeforeReferenceNode() || acceptNode(node) != NodeFilter::FILTER_ACCEPT)
        node = findNextNode(node);
    if (node)
        setReferenceNode(node);
    setPointerBeforeReferenceNode(false);
    return node;
}
Example #18
0
void zmq::session_base_t::detach ()
{
    //  Engine is dead. Let's forget about it.
    engine = NULL;

    //  Remove any half-done messages from the pipes.
    clean_pipes ();

    //  Send the event to the derived class.
    detached ();

    //  Just in case there's only a delimiter in the pipe.
    if (pipe)
        pipe->check_read ();
}
Example #19
0
void zmq::session_t::process_attach (i_engine *engine_,
    const blob_t &peer_identity_)
{
    //  If some other object (e.g. init) notifies us that the connection failed
    //  we need to start the reconnection process.
    if (!engine_) {
        zmq_assert (!engine);
        detached ();
        return;
    }

    //  If we are already terminating, we destroy the engine straight away.
    if (finalised) {
        delete engine;
        return;
    }

    //  Check whether the required pipes already exist. If not so, we'll
    //  create them and bind them to the socket object.
    reader_t *socket_reader = NULL;
    writer_t *socket_writer = NULL;

    if (options.requires_in && !out_pipe) {
        create_pipe (socket, this, options.hwm, options.swap, &socket_reader,
            &out_pipe);
        out_pipe->set_event_sink (this);
    }

    if (options.requires_out && !in_pipe) {
        create_pipe (this, socket, options.hwm, options.swap, &in_pipe,
            &socket_writer);
        in_pipe->set_event_sink (this);
    }

    if (socket_reader || socket_writer)
        send_bind (socket, socket_reader, socket_writer, peer_identity_);

    //  Plug in the engine.
    zmq_assert (!engine);
    zmq_assert (engine_);
    engine = engine_;
    engine->plug (io_thread, this);

    attach_processed = true;

    //  Trigger the notfication about the attachment.
    attached (peer_identity_);
}
Example #20
0
GLVDetachable& GLVDetachable::parentWindow(Window& v){
	if(&v != mParentWindow){
		if(!detached()){
			if(mParentWindow){
				remGUI(parentWindow());
			}
			mParentWindow = &v;
			disable(glv::DrawBack);
			addGUI(parentWindow());
			//printf("%d\n", parentWindow().created());
		}
		else{
			mParentWindow = &v;
		}
	}
	return *this;
}
Example #21
0
void AbstractDb::detachInternal(Db* otherDb)
{
    if (!attachedDbMap.containsRight(otherDb))
        return;

    if (attachCounter.contains(otherDb))
    {
        attachCounter[otherDb]--;
        return;
    }

    QString dbName = attachedDbMap.valueByRight(otherDb);
    SqlQueryPtr res = exec(QString("DETACH %1;").arg(dbName), Flag::NO_LOCK);
    if (res->isError())
    {
        qCritical() << "Cannot detach" << dbName << " / " << otherDb->getName() << ":" << res->getErrorText();
        return;
    }
    attachedDbMap.removeRight(otherDb);
    emit detached(otherDb);
}
Example #22
0
void scribe::consume(execution_unit* ctx, const void*, size_t num_bytes) {
  CAF_ASSERT(ctx != nullptr);
  CAF_LOG_TRACE(CAF_ARG(num_bytes));
  if (detached()) {
    // we are already disconnected from the broker while the multiplexer
    // did not yet remove the socket, this can happen if an IO event causes
    // the broker to call close_all() while the pollset contained
    // further activities for the broker
    return;
  }
  // keep a strong reference to our parent until we leave scope
  // to avoid UB when becoming detached during invocation
  auto guard = parent_;
  auto& buf = rd_buf();
  CAF_ASSERT(buf.size() >= num_bytes);
  // make sure size is correct, swap into message, and then call client
  buf.resize(num_bytes);
  auto& msg_buf = msg().buf;
  msg_buf.swap(buf);
  invoke_mailbox_element(ctx);
  // swap buffer back to stream and implicitly flush wr_buf()
  msg_buf.swap(buf);
  flush();
}
Example #23
0
void MainWindow::addClip( ClipModel *clipModel, TrackItem *trackItem, bool append )
{
    m_bModified = true;
    qDebug() << "Adding clip item to track" << trackItem->pTrackModel->sName;

    ClipItem* clipItem = new ClipItem( clipModel );
    connect( clipItem, SIGNAL( mouseDown(ClipItem*) ),   SLOT( on_timelineClipGrabbed(ClipItem*) ) );
    connect( clipItem, SIGNAL( mouseUp(ClipItem*) ),     SLOT( on_timelineClipReleased(ClipItem*) ) );
    connect( clipItem, SIGNAL( mouseDouble(ClipItem*) ), SLOT( on_timelineClipDoubleClicked(ClipItem*) ) );
    connect( clipItem, SIGNAL( detached() ),             SLOT( on_timelineClipDetached() ) );
    connect( clipItem, SIGNAL( resized(ClipItem*, ClipItem::ResizeDirection) ), SLOT( on_timelineClipResized(ClipItem*, ClipItem::ResizeDirection) ) );

    clipItem->setParentItem( trackItem );
    clipItem->color = trackItem->pTrackModel->qColor;
    clipItem->setObjectName( "clip_" + QString::number(m_pClipItems.size()) );

    m_pClipItems.append( clipItem );

    clipItem->setZoomParams( m_fSpacing, m_iDivisions );
    m_pScene->invalidate();

    if ( append )
        trackItem->pTrackModel->insert( clipModel );
}
void NodeIteratorImpl::detach(int &/*exceptioncode*/)
{
    if (!detached() && document())
        document()->detachNodeIterator(this);
    setDetached();
}
Example #25
0
void manager::set_parent(abstract_broker* ptr) {
  if (! detached())
    parent_ = ptr;
}