int main( void ) { PLIST list = NULL; INDEX idx; char *service; LoadComplete(); GetServiceList( &list ); printf( WIDE("Available services\n") WIDE("---------------------------\n") ); LIST_FORALL( list, idx, char *, service ) { printf( WIDE("%s\n"), service ); }
int main( int argc, char **argv ) { int n; int bFail = 0; int nSleep; //extern void CPROC LoadComplete(); printf( WIDE("Okay... sending ready\n") ); for( n = 1; n < argc; n++ ) { if( strcmp( argv[n], WIDE("fail") ) == 0 ) bFail = 1; else nSleep = atoi( argv[n] ); } if( argc == 1 ) LoadComplete(); Sleep( nSleep ); return 0; }
void UrlStringBoxLoader::Reqeust() { Waiter->WaitForSignal(HttpClient,SIGNAL(Finished()),this,SLOT(LoadComplete()),this, SLOT(OnFail())); HttpClient->Get(UrlList.at(UrlIterator)); }
/** * \copydoc MythUIType::customEvent() */ void MythUIImage::customEvent(QEvent *event) { if (event->type() == ImageLoadEvent::kEventType) { MythImage *image = NULL; AnimationFrames *animationFrames = NULL; int number = 0; QString filename; bool aborted; ImageLoadEvent *le = static_cast<ImageLoadEvent *>(event); if (le->GetParent() != this) return; image = le->GetImage(); number = le->GetNumber(); filename = le->GetFilename(); animationFrames = le->GetAnimationFrames(); aborted = le->GetAbortState(); m_runningThreads--; d->m_UpdateLock.lockForRead(); QString propFilename = m_imageProperties.filename; d->m_UpdateLock.unlock(); // 1) We aborted loading the image for some reason (e.g. two requests // for same image) // 2) Filename changed since we started this image, so abort to avoid // rendering two different images in quick succession which causes // unsightly flickering if (aborted || (le->GetBasefile() != propFilename)) { if (aborted) LOG(VB_GUI, LOG_DEBUG, QString("Aborted loading image %1") .arg(filename)); if (image) image->DecrRef(); if (animationFrames) { AnimationFrames::iterator it; for (it = animationFrames->begin(); it != animationFrames->end(); ++it) { MythImage *im = (*it).first; if (im) im->DecrRef(); } delete animationFrames; } } else if (animationFrames) { SetAnimationFrames(*animationFrames); delete animationFrames; } else if (image) { // We don't clear until we have the new image ready to display to // avoid unsightly flashing. This isn't currently supported for // animations. if ((m_HighNum == m_LowNum) && !m_animatedImage) Clear(); d->m_UpdateLock.lockForWrite(); if (m_imageProperties.forceSize.isNull()) SetSize(image->size()); MythRect rect(GetFullArea()); rect.setSize(image->size()); SetMinArea(rect); d->m_UpdateLock.unlock(); m_ImagesLock.lock(); if (m_Images[number]) { // If we got to this point, it means this same MythUIImage // was told to reload the same image, so we use the newest // copy of the image. m_Images[number]->DecrRef(); // delete the original } m_Images[number] = image; m_ImagesLock.unlock(); SetRedraw(); d->m_UpdateLock.lockForWrite(); m_LastDisplay = QTime::currentTime(); d->m_UpdateLock.unlock(); } else { // No Images were loaded, so trigger Reset to default Reset(); } emit LoadComplete(); } }
/** * \brief Load the image(s), wraps ImageLoader::LoadImage() */ bool MythUIImage::Load(bool allowLoadInBackground, bool forceStat) { d->m_UpdateLock.lockForRead(); m_Initiator = m_EnableInitiator; QString bFilename = m_imageProperties.filename; bFilename.detach(); d->m_UpdateLock.unlock(); QString filename = bFilename; if (bFilename.isEmpty()) { Clear(); SetMinArea(MythRect()); SetRedraw(); return false; } if (getenv("DISABLETHREADEDMYTHUIIMAGE")) allowLoadInBackground = false; // Don't clear the widget before we need to, otherwise it causes // unsightly flashing. We exclude animations for now since that requires a // deeper fix bool isAnimation = (m_HighNum != m_LowNum) || m_animatedImage; if (isAnimation) Clear(); bool complete = true; QString imagelabel; int j = 0; for (int i = m_LowNum; i <= m_HighNum && !m_animatedImage; i++) { if (!m_animatedImage && m_HighNum != m_LowNum && bFilename.contains("%1")) filename = bFilename.arg(i); ImageProperties imProps = m_imageProperties; imProps.filename = filename; imagelabel = ImageLoader::GenImageLabel(imProps); // Only load in the background if allowed and the image is // not already in our mem cache int cacheMode = kCacheIgnoreDisk; if (forceStat) cacheMode |= (int)kCacheForceStat; int cacheMode2 = kCacheNormal; if (forceStat) cacheMode2 |= (int)kCacheForceStat; bool do_background_load = false; if (allowLoadInBackground) { MythImage *img = GetMythUI()->LoadCacheImage( filename, imagelabel, GetPainter(), static_cast<ImageCacheMode>(cacheMode)); if (img) img->DecrRef(); else do_background_load = true; } if (do_background_load) { SetMinArea(MythRect()); LOG(VB_GUI | VB_FILE, LOG_DEBUG, LOC + QString("Load(), spawning thread to load '%1'").arg(filename)); m_runningThreads++; ImageLoadThread *bImgThread; bImgThread = new ImageLoadThread(this, GetPainter(), imProps, bFilename, i, static_cast<ImageCacheMode>(cacheMode2)); GetMythUI()->GetImageThreadPool()->start(bImgThread, "ImageLoad"); } else { if (!isAnimation && !GetMythUI()->IsImageInCache(imagelabel)) Clear(); // Perform a blocking load LOG(VB_GUI | VB_FILE, LOG_DEBUG, LOC + QString("Load(), loading '%1' in foreground").arg(filename)); bool aborted = false; if (ImageLoader::SupportsAnimation(filename)) { AnimationFrames *myFrames; myFrames = ImageLoader::LoadAnimatedImage(GetPainter(), imProps, static_cast<ImageCacheMode>(cacheMode2), this, aborted); // TODO We might want to handle an abort here more gracefully if (aborted) LOG(VB_GUI, LOG_DEBUG, QString("Aborted loading animated" "image %1 in foreground") .arg(filename)); SetAnimationFrames(*myFrames); delete myFrames; } else { MythImage *image = NULL; image = ImageLoader::LoadImage(GetPainter(), imProps, static_cast<ImageCacheMode>(cacheMode2), this, aborted); // TODO We might want to handle an abort here more gracefully if (aborted) LOG(VB_GUI, LOG_DEBUG, QString("Aborted loading animated" "image %1 in foreground") .arg(filename)); if (image) { if (m_imageProperties.forceSize.isNull()) SetSize(image->size()); MythRect rect(GetFullArea()); rect.setSize(image->size()); SetMinArea(rect); m_ImagesLock.lock(); m_Images[j] = image; m_ImagesLock.unlock(); SetRedraw(); d->m_UpdateLock.lockForWrite(); m_LastDisplay = QTime::currentTime(); d->m_UpdateLock.unlock(); } else { Reset(); m_ImagesLock.lock(); m_Images[j] = NULL; m_ImagesLock.unlock(); } } } ++j; // Load is complete if no image is loading in background complete &= !do_background_load; } if (complete) emit LoadComplete(); return true; }