Reduce amount of warnings (#2233)

* Deal with QT depracated warnings
This commit is contained in:
karliss 2020-06-06 19:02:24 +03:00 committed by GitHub
parent 837dd63e6b
commit 76773eadd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 31 additions and 28 deletions

View File

@ -196,8 +196,8 @@ QJsonDocument ColorThemeWorker::getTheme(const QString& themeName) const
return QJsonDocument();
}
QStringList sl;
for (auto &line : QString(src.readAll()).split('\n', QString::SkipEmptyParts)) {
sl = line.replace("#~", "ec ").replace("rgb:", "#").split(' ', QString::SkipEmptyParts);
for (auto &line : QString(src.readAll()).split('\n', CUTTER_QT_SKIP_EMPTY_PARTS)) {
sl = line.replace("#~", "ec ").replace("rgb:", "#").split(' ', CUTTER_QT_SKIP_EMPTY_PARTS);
if (sl.size() != 3 || sl[0][0] == '#') {
continue;
}
@ -320,7 +320,7 @@ bool ColorThemeWorker::isFileTheme(const QString& filePath, bool* ok) const
// The below construct mimics the behaviour of QRegexP::exactMatch(), which was here before
QRegularExpression regexp("\\A(?:" + pattern + ")\\z");
for (auto &line : QString(f.readAll()).split('\n', QString::SkipEmptyParts)) {
for (auto &line : QString(f.readAll()).split('\n', CUTTER_QT_SKIP_EMPTY_PARTS)) {
line.replace("#~", "ec ");
if (!line.isEmpty() && !regexp.match(line).hasMatch()) {
*ok = true;

View File

@ -665,7 +665,7 @@ QStringList Configuration::getAvailableTranslations()
}
}
QStringList fileNames = fileNamesSet.toList();
QStringList fileNames = fileNamesSet.values();
std::sort(fileNames.begin(), fileNames.end());
QStringList languages;
QString currLanguageName;

View File

@ -21,6 +21,12 @@ class QMenu;
class QPaintDevice;
class QComboBox;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#define CUTTER_QT_SKIP_EMPTY_PARTS QString::SkipEmptyParts
#else
#define CUTTER_QT_SKIP_EMPTY_PARTS Qt::SkipEmptyParts
#endif
namespace qhelpers {
QString formatBytecount(const uint64_t bytecount);
void adjustColumns(QTreeView *tv, int columnCount, int padding);

View File

@ -606,9 +606,6 @@ bool CutterCore::loadFile(QString path, ut64 baddr, ut64 mapaddr, int perms, int
r_core_cmd0 (core, "omfg+w");
}
ut64 hashLimit = getConfigut64("cfg.hashlimit");
r_bin_file_compute_hashes(core->bin, hashLimit);
fflush(stdout);
return true;
}
@ -999,7 +996,7 @@ QString CutterCore::getConfigDescription(const char *k)
{
CORE_LOCK();
RConfigNode *node = r_config_node_get (core->config, k);
return QString(node->desc);
return node ? QString(node->desc) : QString("Unrecognized configuration key");
}
void CutterCore::triggerRefreshAll()

View File

@ -26,6 +26,7 @@ class R2TaskDialog;
#include "plugins/CutterPlugin.h"
#include "common/BasicBlockHighlighter.h"
#include "common/R2Task.h"
#include "common/Helpers.h"
#include "dialogs/R2TaskDialog.h"
#define Core() (CutterCore::instance())
@ -108,7 +109,7 @@ public:
QJsonDocument cmdj(const char *str);
QJsonDocument cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); }
QStringList cmdList(const char *str) { return cmd(str).split(QLatin1Char('\n'), QString::SkipEmptyParts); }
QStringList cmdList(const char *str) { return cmd(str).split(QLatin1Char('\n'), CUTTER_QT_SKIP_EMPTY_PARTS); }
QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); }
QString cmdTask(const QString &str);
QJsonDocument cmdjTask(const QString &str);

View File

@ -226,7 +226,7 @@ QVariant XrefModel::data(const QModelIndex &index, int role) const
case FlagDescriptionRole:
return QVariant::fromValue(xref);
default:
return QVariant();
break;
}
return QVariant();
}

View File

@ -56,9 +56,9 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main
actionSetBits32(this),
actionSetBits64(this),
actionContinueUntil(this),
actionSetPC(this),
actionAddBreakpoint(this),
actionAdvancedBreakpoint(this),
actionSetPC(this),
actionSetToCode(this),
actionSetAsStringAuto(this),
actionSetAsStringRemove(this),
@ -1003,9 +1003,7 @@ void DisassemblyContextMenu::on_actionEditFunction_triggered()
QString startAddrText = "0x" + QString::number(fcn->addr, 16);
dialog.setStartAddrText(startAddrText);
QString stackSizeText;
stackSizeText.sprintf("%d", fcn->stack);
dialog.setStackSizeText(stackSizeText);
dialog.setStackSizeText(QString::number(fcn->stack));
QStringList callConList = Core()->cmdRaw("afcl").split("\n");
callConList.removeLast();

View File

@ -118,7 +118,7 @@ QVector<QDir> PluginManager::getPluginDirectories() const
QChar listSeparator = QDir::listSeparator();
#endif
QString extra_plugin_dirs = CUTTER_EXTRA_PLUGIN_DIRS;
for (auto& path : extra_plugin_dirs.split(listSeparator, QString::SplitBehavior::SkipEmptyParts)) {
for (auto& path : extra_plugin_dirs.split(listSeparator, CUTTER_QT_SKIP_EMPTY_PARTS)) {
result.push_back(QDir(path));
}

View File

@ -102,19 +102,18 @@ private:
QCompleter *completer;
QShortcut *historyUpShortcut;
QShortcut *historyDownShortcut;
FILE *origStderr;
FILE *origStdout;
FILE *origStdin;
QLocalSocket *pipeSocket;
FILE *origStderr = nullptr;
FILE *origStdout = nullptr;
FILE *origStdin = nullptr;
QLocalSocket *pipeSocket = nullptr;
#ifdef Q_OS_WIN
HANDLE hRead;
HANDLE hWrite;
#else
int redirectPipeFds[2];
int stdinFile;
int stdinFile = -1;
QString stdinFifoPath;
QVector<char> *redirectionBuffer;
QSocketNotifier *outputNotifier;
#endif
};

View File

@ -1241,7 +1241,11 @@ void DisassemblerGraphView::wheelEvent(QWheelEvent *event)
if (!numDegrees.isNull()) {
int numSteps = numDegrees.y() / 15;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QPointF relativeMousePos = event->pos();
#else
QPointF relativeMousePos = event->position();
#endif
relativeMousePos.rx() /= size().width();
relativeMousePos.ry() /= size().height();

View File

@ -528,10 +528,9 @@ void HexWidget::mouseReleaseEvent(QMouseEvent *event)
void HexWidget::wheelEvent(QWheelEvent *event)
{
int dy = event->delta();
int64_t delta = 3 * itemRowByteLen();
if (dy > 0)
delta = -delta;
// according to Qt doc 1 row per 5 degrees, angle measured in 1/8 of degree
int dy = event->angleDelta().y() / (8 * 5);
int64_t delta = -dy * itemRowByteLen();
if (dy == 0)
return;

View File

@ -41,7 +41,7 @@ protected:
std::unique_ptr<Ui::ListDockWidget> ui;
private:
AddressableFilterProxyModel *objectFilterProxyModel;
AddressableFilterProxyModel *objectFilterProxyModel = nullptr;
CutterTreeWidget *tree;
SearchBarPolicy searchBarPolicy;
};

View File

@ -41,7 +41,6 @@ class ResourcesWidget : public ListDockWidget
private:
ResourcesModel *model;
AddressableFilterProxyModel *filterModel;
CutterTreeView *view;
QList<ResourcesDescription> resources;
public:

View File

@ -58,7 +58,7 @@ VisualNavbar::VisualNavbar(MainWindow *main, QWidget *parent) :
this->graphicsView->setMinimumHeight(15);
this->graphicsView->setMaximumHeight(15);
this->graphicsView->setFrameShape(QFrame::NoFrame);
this->graphicsView->setRenderHints(0);
this->graphicsView->setRenderHints({});
this->graphicsView->setScene(graphicsScene);
this->graphicsView->setRenderHints(QPainter::Antialiasing);
this->graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);