mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kioslave: keep reference to the QByteArray object in CursorCreator::create()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
2c81ba5423
commit
24fa2781e2
2 changed files with 24 additions and 15 deletions
|
@ -35,19 +35,28 @@ extern "C"
|
|||
}
|
||||
}
|
||||
|
||||
bool CursorCreator::create( const QString &path, int width, int height, QImage &img )
|
||||
CursorCreator::CursorCreator()
|
||||
{
|
||||
XcursorImage *cursor = XcursorFilenameLoadImage(
|
||||
QFile::encodeName( path ).data(),
|
||||
width > height ? height : width );
|
||||
}
|
||||
|
||||
if ( cursor ) {
|
||||
img = QImage( reinterpret_cast<uchar *>( cursor->pixels ),
|
||||
cursor->width, cursor->height, QImage::Format_ARGB32_Premultiplied );
|
||||
bool CursorCreator::create(const QString &path, int width, int height, QImage &img)
|
||||
{
|
||||
const QByteArray pathbytes = QFile::encodeName(path);
|
||||
XcursorImage *cursor = XcursorFilenameLoadImage(
|
||||
pathbytes.constData(),
|
||||
width > height ? height : width
|
||||
);
|
||||
|
||||
if (cursor) {
|
||||
img = QImage(
|
||||
reinterpret_cast<uchar*>(cursor->pixels),
|
||||
cursor->width, cursor->height,
|
||||
QImage::Format_ARGB32_Premultiplied
|
||||
);
|
||||
|
||||
// Create a deep copy of the image so the image data is preserved
|
||||
img = img.copy();
|
||||
XcursorImageDestroy( cursor );
|
||||
XcursorImageDestroy(cursor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _CURSORCREATOR_H_
|
||||
#define _CURSORCREATOR_H_
|
||||
#ifndef CURSORCREATOR_H
|
||||
#define CURSORCREATOR_H
|
||||
|
||||
#include <kio/thumbcreator.h>
|
||||
|
||||
class CursorCreator : public ThumbCreator
|
||||
{
|
||||
public:
|
||||
CursorCreator() {}
|
||||
bool create( const QString &path, int, int, QImage &img );
|
||||
public:
|
||||
CursorCreator();
|
||||
|
||||
bool create(const QString &path, int width, int height, QImage &img) final;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CURSORCREATOR_H
|
||||
|
|
Loading…
Add table
Reference in a new issue