From bead166c4f43775364c1afeeae8afeade2969259 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 24 May 2006 10:53:56 +0000 Subject: [PATCH] asl : fix bug 12468 : bad view dump is generated --- src/Plot2d/Plot2d_ViewWindow.cxx | 4 ++-- src/Plot2d/Plot2d_ViewWindow.h | 2 +- src/SUIT/SUIT_ViewWindow.cxx | 15 ++++++++++----- src/SUIT/SUIT_ViewWindow.h | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index eda8bd6fb..2134ef86d 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -500,11 +500,11 @@ QImage Plot2d_ViewWindow::dumpView() \param fileName - name of file \param format - string contains name of format (for example, "BMP"(default) or "JPEG", "JPG") */ -bool Plot2d_ViewWindow::dumpViewToFormat( const QString& fileName, const QString& format ) +bool Plot2d_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ) { bool res = myViewFrame ? myViewFrame->print( fileName, format ) : false; if( !res ) - res = SUIT_ViewWindow::dumpViewToFormat( fileName, format ); + res = SUIT_ViewWindow::dumpViewToFormat( img, fileName, format ); return res; } diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index ec0e5bf64..010359ee1 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -52,7 +52,7 @@ public: protected: virtual QImage dumpView(); virtual QString filter() const; - virtual bool dumpViewToFormat( const QString& fileName, const QString& format ); + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); private: bool eventFilter(QObject* watched, QEvent* e); diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index a0e154a81..149748729 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -83,9 +83,8 @@ QImage SUIT_ViewWindow::dumpView() \param fileName - name of file \param format - string contains name of format (for example, "BMP"(default) or "JPEG", "JPG") */ -bool SUIT_ViewWindow::dumpViewToFormat( const QString& fileName, const QString& format ) +bool SUIT_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ) { - QImage img = dumpView(); if( img.isNull() ) return false; @@ -121,8 +120,12 @@ void SUIT_ViewWindow::contextMenuEvent ( QContextMenuEvent * e ) */ void SUIT_ViewWindow::onDumpView() { - qApp->postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); - qApp->postEvent( this, new QCustomEvent( DUMP_EVENT ) ); + qApp->processEvents(); + qApp->sendEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); + QImage im = dumpView(); + QCustomEvent* e = new QCustomEvent( DUMP_EVENT ); + e->setData( &im ); + qApp->sendEvent( this, e ); } /*! @@ -148,7 +151,9 @@ bool SUIT_ViewWindow::event( QEvent* e ) if( !fileName.isEmpty() ) { QString fmt = SUIT_Tools::extension( fileName ).upper(); - bOk = dumpViewToFormat( fileName, fmt ); + QCustomEvent* ce = ( QCustomEvent* )e; + QImage* im = ( QImage* )ce->data(); + bOk = dumpViewToFormat( *im, fileName, fmt ); } else { diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index c32e6776a..493379eba 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -47,7 +47,7 @@ public: bool event(QEvent*); virtual QImage dumpView(); - virtual bool dumpViewToFormat( const QString& fileName, const QString& format ); + virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format ); bool onAccelAction( int ); -- 2.39.2