void EventDispatcherEPollPrivate::unregisterSocketNotifier(QSocketNotifier* notifier) { Q_ASSERT(notifier != 0); Q_ASSUME(notifier != 0); SocketNotifierHash::Iterator it = this->m_notifiers.find(notifier); if (Q_LIKELY(it != this->m_notifiers.end())) { HandleData* info = it.value(); int fd = static_cast<int>(notifier->socket()); this->m_notifiers.erase(it); // Hash is not rehashed HandleHash::Iterator hi = this->m_handles.find(fd); Q_ASSERT(hi != this->m_handles.end()); struct epoll_event e; e.data.fd = fd; if (info->sni.r == notifier) { info->sni.events &= ~EPOLLIN; info->sni.r = 0; } else if (info->sni.w == notifier) { info->sni.events &= ~EPOLLOUT; info->sni.w = 0; } else if (info->sni.x == notifier) { info->sni.events &= ~EPOLLPRI; info->sni.x = 0; } else { qFatal("%s: internal error: cannot find socket notifier", Q_FUNC_INFO); } e.events = info->sni.events; int res; if (info->sni.r || info->sni.w || info->sni.x) { res = epoll_ctl(this->m_epoll_fd, EPOLL_CTL_MOD, fd, &e); } else { res = epoll_ctl(this->m_epoll_fd, EPOLL_CTL_DEL, fd, &e); if (Q_UNLIKELY(res != 0 && EBADF == errno)) { res = 0; } this->m_handles.erase(hi); delete info; } if (Q_UNLIKELY(res != 0)) { qErrnoWarning("%s: epoll_ctl() failed", Q_FUNC_INFO); } } }
void TimeLineCells::paintEvent( QPaintEvent* event ) { Q_UNUSED( event ); Object* object = mEditor->object(); Layer* layer = mEditor->layers()->currentLayer(); Q_ASSUME( object != nullptr && layer != nullptr ); QPainter painter( this ); bool isPlaying = mEditor->playback()->isPlaying(); if ( ( !isPlaying && !timeLine->scrubbing ) || m_pCache == NULL ) { drawContent(); } if ( m_pCache ) { painter.drawPixmap( QPoint( 0, 0 ), *m_pCache ); } if ( m_eType == TIMELINE_CELL_TYPE::Tracks ) { if (!isPlaying) { paintOnionSkin(painter); } // --- draw the position of the current frame if ( mEditor->currentFrame() > frameOffset ) { painter.setBrush( QColor( 255, 0, 0, 128 ) ); painter.setPen( Qt::NoPen ); painter.setFont( QFont( "helvetica", 10 ) ); //painter.setCompositionMode(QPainter::CompositionMode_Source); // this causes the message: QPainter::setCompositionMode: PorterDuff modes not supported on device QRect scrubRect; scrubRect.setTopLeft( QPoint( getFrameX( mEditor->currentFrame() - 1 ), 0 ) ); scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), height() ) ); if ( shortScrub ) { scrubRect.setBottomRight( QPoint( getFrameX( mEditor->currentFrame() ), 19 ) ); } painter.drawRect( scrubRect ); painter.setPen( QColor( 70, 70, 70, 255 ) ); int incr = 0; if ( mEditor->currentFrame() < 10 ) { incr = 4; } else { incr = 0; } painter.drawText( QPoint( getFrameX( mEditor->currentFrame() - 1 ) + incr, 15 ), QString::number( mEditor->currentFrame() ) ); } } }
void EventDispatcherEPollPrivate::registerSocketNotifier(QSocketNotifier* notifier) { Q_ASSERT(notifier != 0); Q_ASSUME(notifier != 0); int events = 0; QSocketNotifier** n = 0; int fd = static_cast<int>(notifier->socket()); epoll_event e; e.data.fd = fd; HandleData* data; HandleHash::Iterator it = this->m_handles.find(fd); if (it == this->m_handles.end()) { data = new HandleData; data->type = htSocketNotifier; data->sni.r = 0; data->sni.w = 0; data->sni.x = 0; switch (notifier->type()) { case QSocketNotifier::Read: events = EPOLLIN; n = &data->sni.r; break; case QSocketNotifier::Write: events = EPOLLOUT; n = &data->sni.w; break; case QSocketNotifier::Exception: events = EPOLLPRI; n = &data->sni.x; break; default: Q_UNREACHABLE(); } data->sni.events = events; e.events = events; *n = notifier; int res = epoll_ctl(this->m_epoll_fd, EPOLL_CTL_ADD, fd, &e); if (Q_UNLIKELY(res != 0)) { qErrnoWarning("%s: epoll_ctl() failed", Q_FUNC_INFO); delete data; return; } this->m_handles.insert(fd, data); } else { data = it.value(); Q_ASSERT(data->type == htSocketNotifier); if (data->type == htSocketNotifier) { switch (notifier->type()) { case QSocketNotifier::Read: events = EPOLLIN; n = &data->sni.r; break; case QSocketNotifier::Write: events = EPOLLOUT; n = &data->sni.w; break; case QSocketNotifier::Exception: events = EPOLLPRI; n = &data->sni.x; break; default: Q_UNREACHABLE(); } Q_ASSERT(n != 0); if (Q_UNLIKELY(*n != 0)) { qWarning("%s: cannot add two socket notifiers of the same type for the same descriptor", Q_FUNC_INFO); return; } Q_ASSERT((data->sni.events & events) == 0); data->sni.events |= events; e.events = data->sni.events; *n = notifier; int res = epoll_ctl(this->m_epoll_fd, EPOLL_CTL_MOD, fd, &e); if (Q_UNLIKELY(res != 0)) { qErrnoWarning("%s: epoll_ctl() failed", Q_FUNC_INFO); return; } } else { Q_UNREACHABLE(); } } Q_ASSERT(!this->m_notifiers.contains(notifier)); this->m_notifiers.insert(notifier, data); }