Example #1
0
File: gl.cpp Project: nyorain/ny
//GlContext
GlContext::~GlContext()
{
	//if current we ignore it and simply unregister it anyways
	//either the implementation is leaking or destroyed the context without making
	//it not current (in which case - if it did not raise an error - we can try to ignore it).
	if(isCurrent())
	{
		warning("ny::~GlContext: context is current on destruction");

		std::mutex* mutex;
		auto& map = contextCurrentMap(mutex);

		{
			std::lock_guard<std::mutex> lock(*mutex);
			map[std::this_thread::get_id()] = {nullptr, nullptr};
		}
	}

	{
		std::lock_guard<std::mutex> lock(contextShareMutex());
		for(auto& c : shared_)
		{
			if(!c->removeShared(*this))
				warning("ny::~GlContext: context->removeShared(*this) failed");
		}
	}
}
Example #2
0
QVariant MLModel::data( const QModelIndex &index, const int role ) const
{
    if( index.isValid() )
    {
        if( role == Qt::DisplayRole || role == Qt::EditRole )
        {
            MLItem *it = static_cast<MLItem*>( index.internalPointer() );
            if( !it ) return QVariant();
            QVariant tmp = it->data( columnType( index.column() ) );
            return tmp;
        }
        else if( role == Qt::DecorationRole && index.column() == 0  )
        {
            /*
                FIXME: (see ml_type_e)
                media->type uses flags for media type information
            */
            return QVariant( icons[ getInputItem(index)->i_type ] );
        }
        else if( role == IsLeafNodeRole )
            return isLeaf( index );
        else if( role == IsCurrentsParentNodeRole )
            return isParent( index, currentIndex() );
        else if( role == IsCurrentRole )
        {
            return QVariant( isCurrent( index ) );
        }
    }
    return QVariant();
}
Example #3
0
IrcCommandInfo IrcCommandParserPrivate::parseSyntax(IrcCommand::Type type, const QString& syntax)
{
    IrcCommandInfo cmd;
    QStringList tokens = syntax.split(QLatin1Char(' '), QString::SkipEmptyParts);
    if (!tokens.isEmpty()) {
        cmd.type = type;
        cmd.command = tokens.takeFirst().toUpper();
        cmd.syntax = tokens.join(QLatin1String(" "));
        cmd.max = tokens.count();

        IrcParameterInfo param;
        for (int i = 0; i < tokens.count(); ++i) {
            const QString& token = tokens.at(i);
            param.optional = isOptional(token);
            param.channel = isChannel(token);
            param.current = isCurrent(token);
            param.multi = isMultiWord(token);
            if (!param.optional)
                ++cmd.min;
            if (param.optional && param.channel)
                ++cmd.min;
            const bool last = (i == tokens.count() - 1);
            if (last && param.multi)
                cmd.max = INT_MAX;
            cmd.params += param;
        }
    }
    return cmd;
}
Example #4
0
void Window::doneCurrent() const
{
    if( !isCurrent( ))
        return;

    aglSetCurrentContext( 0 );
    WindowIF::doneCurrent();
}
Example #5
0
/**
 * \brief Sets the current value of this field to \a value.
 *
 * \sa value()
 */
void BoolField::setValue(bool value)
{
    if (value != _value) {
        _value = value;
        if (isCurrent())
            printValue();
    }
}
void EglManager::destroySurface(EGLSurface surface) {
    if (isCurrent(surface)) {
        makeCurrent(EGL_NO_SURFACE);
    }
    if (!eglDestroySurface(mEglDisplay, surface)) {
        ALOGW("Failed to destroy surface %p, error=%s", (void*)surface, eglErrorString());
    }
}
Example #7
0
void Window::doneCurrent() const
{
    LBASSERT( _impl->xDisplay );
    if( !isCurrent( ))
        return;

    glXMakeCurrent( _impl->xDisplay, 0, 0 );
    WindowIF::doneCurrent();
}
Example #8
0
void Thread::cancel()
{
    EQASSERTINFO( !isCurrent(), "Thread::cancel called from child thread" );

    EQINFO << "Canceling thread " << className( this ) << std::endl;
    _state = STATE_STOPPING;

    pthread_cancel( _id._data->pthread );
}
Example #9
0
void Thread::cancel()
{
    LBASSERTINFO( !isCurrent(), "Thread::cancel called from child thread" );

    LBINFO << "Canceling thread " << className( this ) << std::endl;
    _impl->state = STATE_STOPPING;

    pthread_cancel( _impl->id._impl->pthread );
}
Example #10
0
 /**
  * Just a performance optimization. Sometimes it makes sense to verify a log
  * when we are inserting a new entry. We combine this into one operation so
  * that we don't iterate through the log twice.
  *
  * As opposed to the simple insert function, this /does/ check to see if the
  * object has already been inserted. In the case where the object already
  * exists and is current, we don't add it again.
  *
  * If the verification fails we'll abort
  *
  * @param shared  The address of the object that we read from.
  * @param version The version of the object that we read.
  *
  * @throws        stm::RollBack
  */
 void insertAndVerifyReads(Object* shared, unsigned long version) {
   assert(shared);
   for (ReadLog::iterator i = reads.begin(), e = reads.end(); i != e; ++i) {
     if (!isCurrent(i->shared, i->version))
       abort();
     if (shared == i->shared)
       return;
   }
   reads.insert(ReadLogEntry(shared, version));
 }
Example #11
0
void TabbedWebView::titleChanged()
{
    const QString &t = title();

    if (isCurrent()) {
        p_QupZilla->setWindowTitle(tr("%1 - QupZilla").arg(t));
    }

    m_tabWidget->setTabText(tabIndex(), t);
}
Example #12
0
void TabbedWebView::urlChanged(const QUrl &url)
{
    if (isCurrent()) {
        p_QupZilla->navigationBar()->refreshHistory();
    }

    if (lastUrl() != url) {
        emit changed();
    }
}
Example #13
0
void TabbedWebView::loadingProgress(int prog)
{
    if (prog > 60) {
        checkRss();
    }

    if (isCurrent()) {
        p_QupZilla->updateLoadingActions();
    }
}
Example #14
0
void EglManager::destroySurface(EGLSurface surface) {
    if (isCurrent(surface)) {
        makeCurrent(EGL_NO_SURFACE);
    }
    EGLBoolean success;
    TIME_LOG("eglDestroySurface", success = eglDestroySurface(mEglDisplay, surface));
    if (!success) {
        ALOGW("Failed to destroy surface %p, error=%s", (void*)surface, egl_error_str());
    }
}
Example #15
0
void SessionChildItem::receiveMessage(IrcMessage* message)
{
    AbstractSessionItem::receiveMessage(message);
    if (message->type() == IrcMessage::Private)
    {
        IrcPrivateMessage* privMsg = static_cast<IrcPrivateMessage*>(message);

        QString alertText;
        if (isChannel())
        {
            if (privMsg->message().contains(m_parent->session()->nickName(), Qt::CaseInsensitive))
            {
                setHighlighted(true);
                if (!isCurrent())
                    alertText = tr("%1 on %2:\n%3").arg(privMsg->sender().name()).arg(title()).arg(privMsg->message());
            }
        }
        else
        {
            setHighlighted(true);
            if (!isCurrent())
                alertText = tr("%1 in private:\n%2").arg(privMsg->sender().name()).arg(privMsg->message());
        }

        if (!alertText.isEmpty())
        {
            setAlertText(alertText);
            emit alert(this);
        }

        if (!isCurrent())
            setUnreadCount(unreadCount() + 1);
    }
    else if (message->type() == IrcMessage::Numeric)
    {
        IrcNumericMessage* numMsg = static_cast<IrcNumericMessage*>(message);
        if (isChannel() && numMsg->code() == Irc::RPL_TOPIC)
            setSubtitle(numMsg->parameters().value(2));
        else if (!isChannel() && numMsg->code() == Irc::RPL_WHOISUSER)
            setSubtitle(numMsg->parameters().value(5));
    }
}
Example #16
0
void Thread::cancel()
{
    LBASSERTINFO( !isCurrent(), "Thread::cancel called from child thread" );

    LBVERB << "Canceling thread " << className( this ) << std::endl;
    _impl->state = STATE_STOPPING;

    const int error = pthread_cancel( _impl->id._impl->pthread );
    if( error !=  0 )
        LBWARN << "Could not cancel thread: " << strerror( error ) << std::endl;
}
Example #17
0
void TabbedWebView::slotLoadFinished()
{
    m_tabWidget->stopTabAnimation(tabIndex());

    showIcon();
    QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));

    if (isCurrent()) {
        p_QupZilla->updateLoadingActions();
    }
}
Example #18
0
void Thread::exit()
{
    EQASSERTINFO( isCurrent(), "Thread::exit not called from child thread" );
    EQINFO << "Exiting thread " << className( this ) << std::endl;
    Log::instance().forceFlush();
    Log::instance().exit();

    _state = STATE_STOPPING;
    pthread_exit( 0 );
    EQUNREACHABLE;
}
Example #19
0
void TabbedWebView::setIp(const QHostInfo &info)
{
    if (info.addresses().isEmpty()) {
        return;
    }

    m_currentIp = info.hostName() + " (" + info.addresses().at(0).toString() + ")";

    if (isCurrent()) {
        emit ipChanged(m_currentIp);
    }
}
Example #20
0
void Window::makeCurrent( const bool cache ) const
{
    LBASSERT( _impl->xDisplay );
    if( cache && isCurrent( ))
        return;

    glXMakeCurrent( _impl->xDisplay, _impl->xDrawable, _impl->glXContext );
    WindowIF::makeCurrent();
    if( _impl->glXContext )
    {
        EQ_GL_ERROR( "After glXMakeCurrent" );
    }
}
Example #21
0
bool Thread::join()
{
    if( _state == STATE_STOPPED )
        return false;
    if( isCurrent( )) // can't join self
        return false;

    _state.waitNE( STATE_RUNNING );
    _state = STATE_STOPPED;

    EQINFO << "Joined thread " << className( this ) << std::endl;
    return true;
}
Example #22
0
void Window::makeCurrent( const bool cache ) const
{
    if( cache && isCurrent( ))
        return;

    aglSetCurrentContext( _impl->aglContext );
    WindowIF::makeCurrent();

    if( _impl->aglContext )
    {
        EQ_GL_ERROR( "After aglSetCurrentContext" );
    }
}
Example #23
0
void TabbedWebView::slotLoadFinished()
{
    QMovie* mov = animationLoading(tabIndex(), false)->movie();
    if (mov) {
        mov->stop();
    }

    showIcon();
    QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));

    if (isCurrent()) {
        p_QupZilla->updateLoadingActions();
    }
}
Example #24
0
		void EditMode::populateContextMenu(QMenu* menu)
		{
			if(!isCurrent())
			{
				return;
			}

			if (!fragment_db_)
			{
				fragment_db_ = new FragmentDB("fragments/Editing-Fragments.db");
			}

			createContextMenuEntries_();

			menu->addAction(atom_properties_);
			menu->addAction(delete_atom_);
			menu->addAction(element_action_);

			menu->addAction(tr("Delete Bond"), this, SLOT(deleteCurrentBondTriggered_()))->setEnabled(scene_->getCurrentBond() != 0);

			menu->addSeparator();

			QAction* change_charge = menu->addMenu(charge_menu_);
			change_charge->setText(tr("Set formal charge"));
			change_charge->setEnabled(scene_->getCurrentAtom() != 0);

			QAction* change_order = menu->addMenu(order_menu_);
			change_order->setText(tr("Change bond order"));
			change_order->setEnabled(scene_->getCurrentBond() != 0);

			Index bo = 5;
			if (scene_->getCurrentBond()) {
				bo = ((Index)scene_->getCurrentBond()->getOrder());
			}
			checkBondOrderActions_(bo);

			menu->addSeparator();

			QAction* add_action = menu->addMenu(add_menu_);
			add_action->setText(tr("Add"));
			if (scene_->getContainers().empty())
			{
				add_action->setEnabled(false);
			}
			else
			{
				add_action->setEnabled(true);
			}
		}
Example #25
0
	void Menu::enableMusic(bool enable)
	{
		playMusic = enable;

		if (isCurrent())
		{
			if (enable)
			{
				menuTrack.play(false);
			}
			else
			{
				sound.stopMusic();
			}
		}
	}
Example #26
0
void QWebOSGLContext::resizeSurface(const QSize& size)
{
    bool restoreCurrent = false;
    if (isCurrent()) {
        doneCurrent();
        restoreCurrent = true;
    }

    destroySurface();
    m_platformWindow->resize(size.width(), size.height());
    m_surfaceSize = size;
    createSurface();

    if (restoreCurrent) {
        makeCurrent();
    }
}
Example #27
0
    bool RenderTargetFBO::setAttachment( AttachmentTarget target, const SharedAttachment &attachment, StereoTarget stereoTarget )
    {
      int stereoId = getStereoTargetId( stereoTarget );

      m_attachments[stereoId][target] = attachment;

      if ( isCurrent() )
      {
        attachment->bind( target );
      }
      else
      {
        // keep track of changed attachments. This reduces the number of bind calls in bindAttachments()
        // which is being called on beginRendering().
        m_attachmentChanges[stereoId][target] = attachment;
      }
      return true;
    }
Example #28
0
bool EglManager::makeCurrent(EGLSurface surface) {
    if (isCurrent(surface)) return false;

    if (surface == EGL_NO_SURFACE) {
        // If we are setting EGL_NO_SURFACE we don't care about any of the potential
        // return errors, which would only happen if mEglDisplay had already been
        // destroyed in which case the current context is already NO_CONTEXT
        TIME_LOG("eglMakeCurrent", eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
    } else {
        EGLBoolean success;
        TIME_LOG("eglMakeCurrent", success = eglMakeCurrent(mEglDisplay, surface, surface, mEglContext));
        if (!success) {
            LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s",
                (void*)surface, egl_error_str());
        }
    }
    mCurrentSurface = surface;
    return true;
}
Example #29
0
    bool RenderTargetFB::setStereoTarget( StereoTarget target )
    {
      // Only left/mono available in non stereo mode
      if ( !m_stereoEnabled && target != StereoTarget::LEFT )
      {
        return false;
      }

      if ( m_stereoTarget != target )
      {
        m_stereoTarget = target;
        if ( isCurrent() )
        {
          setDrawBuffer( m_stereoTarget );
        }
      }

      return true;
    }
Example #30
0
    bool RenderTargetFBO::setStereoTarget( StereoTarget stereoTarget )
    {
      if ( stereoTarget != m_stereoTarget )
      {
        if (  (!m_stereoEnabled && stereoTarget != StereoTarget::LEFT)          // only mono target supported for non stereo mode
            ||( m_stereoEnabled && stereoTarget == StereoTarget::LEFT_AND_RIGHT ) ) // not supported to render on left/right target at the same time
        {
          return false;
        }

        m_stereoTarget = stereoTarget;
        if ( isCurrent() )
        {
          resizeAttachments( stereoTarget );
          bindAttachments( stereoTarget );
        }
      }
      return true;
    }