Skip to content

Commit

Permalink
Sigviewer is now compatible with Qt 5.3
Browse files Browse the repository at this point in the history
This repository is supposed to work with both Qt 4.8.7 and Qt 5.3
without alteration. Qt versions later than 5.3 are paired up with later
version of MinGW, which I tried but doesn't work, unless we recompile
libbiosig as well. Thus currently Qt 5.3 is the latest Qt version I can
push to. The use of conditional macro makes it backwardly compatible
with Qt 4.8.7 as well.

I found several dynamically allocated arrays was deleted using "delete"
instead of "delete[]". Are these mistakes, or supposed to work like
this?

Do you have suggestions on what else I should improve/work on? Thank
you!
  • Loading branch information
Yida-Lin committed Nov 18, 2016
1 parent 11aafff commit c5b3b03
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/file_handling_impl/biosig_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ QString BioSigReader::loadFixedHeader(const QString& file_name)
sclose (biosig_header_);
destructHDR(biosig_header_);
biosig_header_ = NULL;

//by YL: should it be delete[]?
delete c_file_name;
return "file not supported";
}
Expand All @@ -177,6 +179,7 @@ QString BioSigReader::loadFixedHeader(const QString& file_name)

//hdr2ascii(biosig_header_,stdout,4);

//by YL: should it be delete[]?
delete c_file_name;
c_file_name = NULL;

Expand Down
1 change: 1 addition & 0 deletions src/file_handling_impl/biosig_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ QString BioSigWriter::save (QSharedPointer<FileContext const> file_context,
HDRTYPE* write_header = sopen (new_file_path_.toStdString().c_str(), "w", read_header);
qDebug() << "write NELEM = " << swrite (read_data, read_header->NRec, write_header);

//by YL: should it be delete[]?
delete read_data;

sclose(write_header);
Expand Down
4 changes: 2 additions & 2 deletions src/file_handling_impl/loadxdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ XDFdataStruct load_xdf(std::string filename)

std::cout << "it took " << halfWay << " clicks (" << ((float)halfWay) / CLOCKS_PER_SEC << " seconds)"
<< " reading XDF data" << std::endl;

/*
//try to free up some memory
for (size_t st = 0; st < XDFdata.streams.size(); st++)
{
Expand All @@ -730,7 +730,7 @@ XDFdataStruct load_xdf(std::string filename)
XDFdata.streams[st].time_series[ch].shrink_to_fit();
}
}

*/


//==========================================================
Expand Down
5 changes: 4 additions & 1 deletion src/file_handling_impl/xdf_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ QString XDFReader::loadFixedHeader(const QString& file_name)
sclose (xdf_header_);
destructHDR(xdf_header_);
xdf_header_ = NULL;

//by YL: should it be delete[]?
delete c_file_name;
return "file not supported";
}
Expand All @@ -318,7 +320,8 @@ QString XDFReader::loadFixedHeader(const QString& file_name)

//hdr2ascii(XDF_header_,stdout,4);

delete c_file_name;
//by YL: should it be delete[]? (I already changed this one)
delete[] c_file_name;
c_file_name = NULL;

basic_header_->setNumberEvents(xdf_header_->EVENT.N);
Expand Down
8 changes: 8 additions & 0 deletions src/gui_impl/dialogs/basic_header_info_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,15 @@ void BasicHeaderInfoDialog::buildTree()
QStringList header_labels;
header_labels << tr("Property") << tr("Value") << tr("Unit");
info_tree_widget_->setHeaderLabels(header_labels);
//info_tree_widget_->header()->setResizeMode(QHeaderView::Interactive);

//by YL
#if QT_VERSION >= 0x050000
info_tree_widget_->header()->setSectionResizeMode(QHeaderView::Interactive);
#else
info_tree_widget_->header()->setResizeMode(QHeaderView::Interactive);
#endif


QTreeWidgetItem* root_item;
QTreeWidgetItem* tmp_item;
Expand Down
21 changes: 19 additions & 2 deletions src/gui_impl/dialogs/event_types_selection_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ void EventTypesSelectionDialog::buildTree (bool only_existing_events)
header_labels << tr("Event Type") << tr("Color") << tr("Alpha") << tr("Type Id");
ui_.tree_widget_->setHeaderLabels (header_labels);
ui_.tree_widget_->setColumnWidth(ID_COLUMN_INDEX_, 0);
//ui_.tree_widget_->header()->setResizeMode (QHeaderView::Interactive);

//by YL
#if QT_VERSION >= 0x050000
ui_.tree_widget_->header()->setSectionResizeMode (QHeaderView::Interactive);
#else
ui_.tree_widget_->header()->setResizeMode (QHeaderView::Interactive);
#endif


ui_.tree_widget_->header()->resizeSection (NAME_COLUMN_INDEX_, 300);
ui_.tree_widget_->header()->resizeSection (ID_COLUMN_INDEX_, 0);

Expand Down Expand Up @@ -307,8 +316,16 @@ void EventTypesSelectionDialog::handleAlpha (QTreeWidgetItem* item)

QColor color = item->backgroundColor (ALPHA_COLUMN_INDEX_);

color.setAlpha (QInputDialog::getInteger(this, tr("Alpha"), tr("Enter new Value"),
color.alpha(), 0, 255, 25));
//color.setAlpha (QInputDialog::getInteger(this, tr("Alpha"), tr("Enter new Value"),
// color.alpha(), 0, 255, 25));

//by YL
#if QT_VERSION >= 0x050000
color.setAlpha (QInputDialog::getInt(this, tr("Alpha"), tr("Enter new Value"), color.alpha(), 0, 255, 25));
#else
color.setAlpha (QInputDialog::getInteger(this, tr("Alpha"), tr("Enter new Value"), color.alpha(), 0, 255, 25));
#endif



item->setBackgroundColor (ALPHA_COLUMN_INDEX_, color);
Expand Down
5 changes: 5 additions & 0 deletions src/gui_impl/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#include <QUrl>
#include <QDebug>

//by YL
#if QT_VERSION >= 0x050000
#include <QMimeData>
#endif

namespace SigViewer_
{

Expand Down
4 changes: 4 additions & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ SOURCES += main/sigviewer.cpp \
file_context.cpp \
tab_context.cpp

#by YL

QMAKE_CFLAGS += -std=c99

QMAKE_CXXFLAGS=-std=gnu++11

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

0 comments on commit c5b3b03

Please sign in to comment.