Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from Qt4 to Qt5 #92

Merged
merged 8 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/3rdparty/getopt/getopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ bool GetOpt::parse( bool untilFirstSwitchOnly )
}
if ( t == LongOpt && opt.type == OUnknown ) {
if ( currOpt.type != OVarLen ) {
qWarning( "Unknown option --%s", a.toAscii().data() );
qWarning( "Unknown option --%s", a.toLatin1().data() );
return false;
} else {
// VarLength options support arguments starting with '-'
Expand Down Expand Up @@ -346,7 +346,7 @@ bool GetOpt::parse( bool untilFirstSwitchOnly )
} else {
QString n = currType == LongOpt ?
currOpt.lname : QString( QChar( currOpt.sname ) );
qWarning( "Expected an argument after '%s' option", n.toAscii().data() );
qWarning( "Expected an argument after '%s' option", n.toLatin1().data() );
return false;
}
break;
Expand Down
22 changes: 11 additions & 11 deletions src/algorithms/svmpredict.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
/*
* Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of Gaia
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
*
* You should have received a copy of the Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*/
Expand Down Expand Up @@ -78,7 +78,7 @@ Point* SVMPredict::svmPredict(const Point* p, Point* result,
// predict class (and probabilities)
double predictedClass;
if (_probability) {
GVarLengthArray<double, 32> classProbability(_classMapping.size());
QVarLengthArray<double, 32> classProbability(_classMapping.size());
predictedClass = svm_predict_probability(model, x, classProbability.data());

Real* probs = 0;
Expand Down
24 changes: 12 additions & 12 deletions src/algorithms/svmtrain.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
/*
* Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of Gaia
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
*
* You should have received a copy of the Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*/
Expand Down Expand Up @@ -222,7 +222,7 @@ Transformation SVMTrain::analyze(const DataSet* dataset) const {
QString modelFilename = modelFile.fileName();
modelFile.close();

if (svm_save_model(modelFilename.toAscii().constData(), model) == -1) {
if (svm_save_model(modelFilename.toLatin1().constData(), model) == -1) {
throw GaiaException("SVMTrain: error while saving SVM model to temp file");
}

Expand All @@ -234,7 +234,7 @@ Transformation SVMTrain::analyze(const DataSet* dataset) const {
// if we asked for the model to be output specifically, also do it
if (_params.value("modelFilename", "").toString() != "") {
QString filename = _params.value("modelFilename").toString();
svm_save_model(filename.toAscii().constData(), model);
svm_save_model(filename.toLatin1().constData(), model);
}

// destroy the model allocated by libsvm
Expand Down
16 changes: 3 additions & 13 deletions src/bindings/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from __future__ import print_function
import sys

def print_env(env):
for n in env.m_table.keys():
if 'py' in n or 'PY' in n:
print(n, ':', env[n])


def options(opt):
opt.add_option('--with-python-bindings', action='store_true',
Expand All @@ -22,11 +17,11 @@ def configure(conf):
conf.load('swig python')

if type(conf.env.SWIG) == str:
conf.env.SWIG = [ conf.env.SWIG ]
if conf.check_swig_version() < (1,3,31):
conf.env.SWIG = [conf.env.SWIG]
if conf.check_swig_version() < (3, 0, 12):
conf.fatal('this swig version is too old')

conf.check_python_version((3,5))
conf.check_python_version((3, 7))
conf.check_python_headers()

# do not use the default extension of .bundle on MacOS
Expand All @@ -43,11 +38,6 @@ def configure(conf):


def build(bld):
# fix for waf/python2.6 install paths
#major, minor, _, _, _ = sys.version_info
#if major >= 2 and minor >= 6:
# bld.env['PYTHONDIR'] = bld.env['PYTHONDIR'].replace('site-packages', 'dist-packages')

bld(features = 'cxx cshlib pyext',
source = 'gaia.swig',
target = '_gaia2',
Expand Down
22 changes: 12 additions & 10 deletions src/dataset.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
/*
* Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of Gaia
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
*
* You should have received a copy of the Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*/
Expand Down Expand Up @@ -489,6 +489,8 @@ class DataSet : public PointArray, public QObject {

};

QDataStream& operator<<(QDataStream& out, const DataSet& dataset);
QDataStream& operator>>(QDataStream& in, DataSet& dataset);

} // namespace gaia2

Expand Down
22 changes: 12 additions & 10 deletions src/descriptortree.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*
/*
* Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
*
* This file is part of Gaia
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
*
* Gaia is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation (FSF), either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
*
* You should have received a copy of the Affero GNU General Public License
* version 3 along with this program. If not, see http://www.gnu.org/licenses/
*/
Expand Down Expand Up @@ -313,6 +313,8 @@ class DescriptorTree {
friend QDataStream& operator>>(QDataStream& in, DescriptorTree& tree);
};

QDataStream& operator<<(QDataStream& out, const DescriptorTree& tree);
QDataStream& operator>>(QDataStream& in, DescriptorTree& tree);

} // namespace gaia2

Expand Down
31 changes: 24 additions & 7 deletions src/gaia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,29 @@ const char* version_git_sha = GAIA_GIT_SHA;

// message handler that aborts execution, so that when run inside gdb we can
// still get a stack trace. Very useful!
// got the idea from http://der-dakon.net/blog/KDE/tracing-qassert.html
static void qtMessageHandler(QtMsgType type, const char *msg) {
fprintf(stderr, "%s\n", msg);
if (type == QtFatalMsg) {
abort();
}
// from https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function);
break;
}
}


Expand All @@ -56,7 +73,7 @@ void init() {

QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf-8"));

qInstallMsgHandler(qtMessageHandler);
qInstallMessageHandler(messageHandler);

registerAnalyzers();
registerAppliers();
Expand Down
Loading