[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kooka] /: Compile with QT_NO_CAST_FROM_BYTEARRAY
From:       Jonathan Marten <null () kde ! org>
Date:       2018-03-08 16:01:15
Message-ID: E1etxyl-0002wQ-3I () code ! kde ! org
[Download RAW message or body]

Git commit 160eace74e39087d8962c0306edc4a49d016f1e2 by Jonathan Marten.
Committed on 06/03/2018 at 08:18.
Pushed by marten into branch 'master'.

Compile with QT_NO_CAST_FROM_BYTEARRAY

M  +1    -1    CMakeLists.txt
M  +3    -3    kooka/imageformat.cpp
M  +1    -1    kooka/imageformat.h
M  +2    -2    kooka/kookaimage.cpp
M  +5    -3    kooka/kookapref.cpp
M  +1    -1    kooka/scangallery.cpp
M  +1    -1    libfiletree/filetreebranch.cpp
M  +1    -1    libkookascan/kscancontrols.cpp
M  +2    -2    libkookascan/kscandevice.cpp
M  +3    -3    libkookascan/scandevices.cpp

https://commits.kde.org/kooka/160eace74e39087d8962c0306edc4a49d016f1e2

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a1dad1..6dc6396 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,8 +41,8 @@ include(ECMInstallIcons)
 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Widgets)
 
 # REMOVE IT
-remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY)
 remove_definitions(-DQT_NO_CAST_FROM_ASCII)
+#add_definitions(-DQT_RESTRICTED_CAST_FROM_ASCII)
 remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS)
 
 add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
diff --git a/kooka/imageformat.cpp b/kooka/imageformat.cpp
index 58edbdd..a09a633 100644
--- a/kooka/imageformat.cpp
+++ b/kooka/imageformat.cpp
@@ -61,9 +61,9 @@ bool ImageFormat::isValid() const
     return (!mFormat.isEmpty());
 }
 
-QByteArray ImageFormat::name() const
+const char *ImageFormat::name() const
 {
-    return (mFormat);
+    return (mFormat.constData());
 }
 
 ImageFormat::ImageFormat()
@@ -78,7 +78,7 @@ bool ImageFormat::operator==(const ImageFormat &other)
 
 QDebug operator<<(QDebug stream, const ImageFormat &format)
 {
-    stream.nospace() << "ImageFormat[" << format.name().constData() << "]";
+    stream.nospace() << "ImageFormat[" << format.name() << "]";
     return (stream.space());
 }
 
diff --git a/kooka/imageformat.h b/kooka/imageformat.h
index ff7bca5..bc58ccb 100644
--- a/kooka/imageformat.h
+++ b/kooka/imageformat.h
@@ -45,7 +45,7 @@ public:
     ImageFormat(const QByteArray &format);
 
     bool isValid() const;
-    QByteArray name() const;
+    const char *name() const;
 
     QMimeType mime() const;
     QString extension() const;
diff --git a/kooka/kookaimage.cpp b/kooka/kookaimage.cpp
index 2502625..8b14b1d 100644
--- a/kooka/kookaimage.cpp
+++ b/kooka/kookaimage.cpp
@@ -159,7 +159,7 @@ QString KookaImage::loadFromUrl(const QUrl &url)
     {							// for multiple images
         m_subImages = 0;				// no subimages found yet
         qDebug() << "Checking for multi-page TIFF";
-        TIFF *tif = TIFFOpen(filename.toLatin1(), "r");
+        TIFF *tif = TIFFOpen(QFile::encodeName(filename).constData(), "r");
         if (tif != NULL)
         {
             do
@@ -214,7 +214,7 @@ bool KookaImage::loadTiffDir(const QString &filename, int no)
 
     // if it is TIFF, check with TIFFlib if it is multiple images
     //qDebug() << "Trying to load TIFF, subimage number" << no;
-    TIFF *tif = TIFFOpen(filename.toLatin1(), "r");
+    TIFF *tif = TIFFOpen(QFile::encodeName(filename).constData(), "r");
     if (tif == NULL) {
         return (false);
     }
diff --git a/kooka/kookapref.cpp b/kooka/kookapref.cpp
index 51d6f07..9d41eed 100644
--- a/kooka/kookapref.cpp
+++ b/kooka/kookapref.cpp
@@ -193,9 +193,11 @@ static QString docsPath()
 // TODO: maybe save a .directory file there which shows a 'scanner' logo?
 static QString createGallery(const QDir &d, bool *success = NULL)
 {
-    if (!d.exists()) {                  // does not already exist
-        if (mkdir(d.path().toLocal8Bit(), 0755) != 0) { // using mkdir(2) so that we can
-            // get the errno if it fails
+    if (!d.exists())					// does not already exist
+    {
+        if (mkdir(QFile::encodeName(d.path()).constData(), 0755) != 0)
+        {						// using mkdir(2) so that we can
+							// get the errno if it fails
 #ifdef HAVE_STRERROR
             const char *reason = strerror(errno);
 #else
diff --git a/kooka/scangallery.cpp b/kooka/scangallery.cpp
index a4c41c2..4358508 100644
--- a/kooka/scangallery.cpp
+++ b/kooka/scangallery.cpp
@@ -458,7 +458,7 @@ void ScanGallery::slotDecorate(FileTreeViewItem *item)
         ImageFormat format = getImgFormat(item);	// this is safe for any file
         if (!isSubImage)				// no format for subimages
         {
-            item->setText(2, (QString(" " + format.name() + " ")));
+            item->setText(2, (QString(" %1 ").arg(format.name())));
         }
 
         const KookaImage *img = imageForItem(item);
diff --git a/libfiletree/filetreebranch.cpp b/libfiletree/filetreebranch.cpp
index d5d3720..c54f07f 100644
--- a/libfiletree/filetreebranch.cpp
+++ b/libfiletree/filetreebranch.cpp
@@ -390,7 +390,7 @@ void FileTreeBranch::slotItemsAdded(const QUrl &parent, const KFileItemList &ite
 #endif // DEBUG_LISTING
             //qDebug() << "Doing stat on" << filename;
             struct stat statBuf;
-            if (stat(filename.toLocal8Bit(), &statBuf) == 0) {
+            if (stat(QFile::encodeName(filename).constData(), &statBuf) == 0) {
                 int hardLinks = statBuf.st_nlink;  /* Count of dirs */
 #ifdef DEBUG_LISTING
                 qDebug() << "stat succeeded, hardlinks: " << hardLinks;
diff --git a/libkookascan/kscancontrols.cpp b/libkookascan/kscancontrols.cpp
index 97e1c53..4d2bdf3 100644
--- a/libkookascan/kscancontrols.cpp
+++ b/libkookascan/kscancontrols.cpp
@@ -298,7 +298,7 @@ void KScanCombo::setList(const QList<QByteArray> &list)
     foreach (const QByteArray &item, list)
     {
         // See the KI18N Programmer's Guide, "Connecting to Catalogs in Library Code"
-        mCombo->addItem(ki18n(item).toString("sane-backends"), item);
+        mCombo->addItem(ki18n(item.constData()).toString("sane-backends"), item);
     }
 
     mCombo->blockSignals(bs);
diff --git a/libkookascan/kscandevice.cpp b/libkookascan/kscandevice.cpp
index dcb02b1..958f274 100644
--- a/libkookascan/kscandevice.cpp
+++ b/libkookascan/kscandevice.cpp
@@ -226,13 +226,13 @@ KScanDevice::Status KScanDevice::openDevice(const QByteArray &backend)
     mScannerName = backend;				// set now for authentication
     QApplication::setOverrideCursor(Qt::WaitCursor);	// potential lengthy operation
     ScanGlobal::self()->setScanDevice(this);		// for possible authentication
-    mSaneStatus = sane_open(backend, &mScannerHandle);
+    mSaneStatus = sane_open(backend.constData(), &mScannerHandle);
 
     if (mSaneStatus==SANE_STATUS_ACCESS_DENIED)		// authentication failed?
     {
         clearSavedAuth();				// clear any saved password
         //qDebug() << "retrying authentication";		// try again once more
-        mSaneStatus = sane_open(backend, &mScannerHandle);
+        mSaneStatus = sane_open(backend.constData(), &mScannerHandle);
     }
 
     if (mSaneStatus==SANE_STATUS_GOOD)
diff --git a/libkookascan/scandevices.cpp b/libkookascan/scandevices.cpp
index e8bcee8..247f52a 100644
--- a/libkookascan/scandevices.cpp
+++ b/libkookascan/scandevices.cpp
@@ -160,9 +160,9 @@ void ScanDevices::addUserSpecifiedDevice(const QByteArray &backend,
     // There is only a limited number of these objects in most applications,
     // so hopefully it won't matter too much.
 
-    userdev->name = *(new QByteArray(backend));
-    userdev->model = *(new QByteArray(description.toLocal8Bit()));
-    userdev->type = *(new QByteArray(devtype));
+    userdev->name = (new QByteArray(backend))->constData();
+    userdev->model = (new QByteArray(description.toLocal8Bit()))->constData();
+    userdev->type = (new QByteArray(devtype))->constData();
     userdev->vendor = "User specified";
 
     mScannerNames.append(backend);

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic