Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when loading svg in qimage producer from terminal #19

Merged
merged 3 commits into from
Nov 19, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/modules/qimage/qimage_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
#ifdef USE_QT4
#include <QtGui/QImage>
#include <QtCore/QSysInfo>
#include <QtGui/QApplication>
#include <QtCore/QMutex>
#include <QtCore/QtEndian>
#include <QtCore/QTemporaryFile>
#include <QtCore/QLocale>
#endif

#ifdef USE_EXIF
Expand All @@ -63,6 +65,8 @@ static KComponentData *instance = 0L;
static KInstance *instance = 0L;
#endif

static QApplication *app = NULL;

static void qimage_delete( void *data )
{
QImage *image = ( QImage * )data;
Expand Down Expand Up @@ -178,13 +182,39 @@ int refresh_qimage( producer_qimage self, mlt_frame frame )
sprintf( image_key, "%d", image_idx );

int disable_exif = mlt_properties_get_int( producer_props, "disable_exif" );


if ( app == NULL )
{
if ( qApp )
{
app = qApp;
}
else
{
#ifdef linux
if ( getenv("DISPLAY") == 0 )
{
mlt_log_panic( MLT_PRODUCER_SERVICE( producer ), "Error, cannot render titles without an X11 environment.\nPlease either run melt from an X session or use a fake X server like xvfb:\nxvfb-run -a melt (...)\n" );
exit( 1 );
return -1;
}
#endif
int argc = 1;
char* argv[1];
argv[0] = (char*) "xxx";
app = new QApplication( argc, argv );
const char *localename = mlt_properties_get_lcnumeric( MLT_SERVICE_PROPERTIES( MLT_PRODUCER_SERVICE( producer ) ) );
QLocale::setDefault( QLocale( localename ) );
}
}

if ( image_idx != self->qimage_idx )
self->qimage = NULL;
if ( !self->qimage || mlt_properties_get_int( producer_props, "_disable_exif" ) != disable_exif )
{
self->current_image = NULL;
QImage *qimage = new QImage( mlt_properties_get_value( self->filenames, image_idx ) );
QImage *qimage = new QImage( QString::fromUtf8( mlt_properties_get_value( self->filenames, image_idx ) ) );
self->qimage = qimage;

if ( !qimage->isNull( ) )
Expand Down