Index: canvas.cpp =================================================================== RCS file: /home/kde/kdegraphics/kpaint/canvas.cpp,v retrieving revision 1.32 diff -u -p -r1.32 canvas.cpp --- canvas.cpp 2002/09/25 23:45:28 1.32 +++ canvas.cpp 2002/10/28 23:17:23 @@ -129,6 +129,9 @@ void Canvas::cut() int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); + if (w <= 0 || h <= 0) + return; + QPixmap p( w, h ); p.fill(QColor("white")); @@ -141,16 +144,18 @@ void Canvas::cut() } void Canvas::copy() -{ - int x = haveSelection_ ? selection_.left() : 0; - int y = haveSelection_ ? selection_.top() : 0; - int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); - int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); - kdDebug(4400) << "copying: (" << x << ", " << y << ") - (" << w << ", " << h << ")"; +{ + int x = haveSelection_ ? selection_.left() : 0; + int y = haveSelection_ ? selection_.top() : 0; + int w = haveSelection_ ? selection_.right() - selection_.left() : pix->width(); + int h = haveSelection_ ? selection_.bottom() - selection_.top() : pix->height(); + kdDebug(4400) << "copying: (" << x << ", " << y << ") - (" << w << ", " << h << ")"; + if (w <= 0 || h <= 0) + return; - QPixmap clipboardPix( w, h ); - bitBlt( &clipboardPix, 0, 0, pix, x, y, w, h, CopyROP); - kapp->clipboard()->setPixmap( clipboardPix ); + QPixmap clipboardPix( w, h ); + bitBlt( &clipboardPix, 0, 0, pix, x, y, w, h, CopyROP); + kapp->clipboard()->setPixmap( clipboardPix ); } void Canvas::paste( int x, int y ) Index: kpaint.cpp =================================================================== RCS file: /home/kde/kdegraphics/kpaint/kpaint.cpp,v retrieving revision 1.105 diff -u -p -r1.105 kpaint.cpp --- kpaint.cpp 2002/09/25 23:45:28 1.105 +++ kpaint.cpp 2002/10/28 23:17:23 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ KPaint::KPaint(const KURL & _url) : KMai initStatus(); readOptions(); + enableEditPaste(); connect( kapp->clipboard(), SIGNAL( dataChanged() ), SLOT( enableEditPaste() ) ); resize(640,480); show(); @@ -150,14 +152,7 @@ void KPaint::readOptions() void KPaint::enableEditPaste() { - QClipboard *cb = kapp->clipboard(); - - bool e; - if ( cb->pixmap().isNull() ) - e = false; - else - e = true; - + bool e = KClipboard::provides("image/"); kdDebug() << "kpaint: clipboard has image: " << e << endl; pasteAction->setEnabled( e ); pasteImageAction->setEnabled( e ); @@ -661,8 +656,8 @@ void KPaint::editPaste() kdDebug(4400) << "editPaste()\n" << endl; QClipboard *cb = kapp->clipboard(); - QPixmap clipPix = cb->pixmap(); - if ( !clipPix.isNull() ) + QPixmap clipPix = cb->pixmap(QClipboard::Clipboard); + if ( !clipPix.isNull() && clipPix.width() && clipPix.height() ) man->setCurrentTool(9); m_canvas->markModified();