mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
fix
纠正QQtDictNode list模式内外空间不分离的问题。 纠正QQtSoundEffect在机械硬盘和SSD上不同表现的问题。
This commit is contained in:
parent
eba254b650
commit
1dde4251cd
@ -52,7 +52,10 @@ void QQtDictNode::appendChild ( const QString& value )
|
||||
void QQtDictNode::appendChild ( const QQtDictNode& dict )
|
||||
{
|
||||
m_type = DictList;
|
||||
m_list.append ( dict );
|
||||
//list类
|
||||
//append函数,会引用外部变量,push_back是不是在list内部生成了新的实例?
|
||||
//m_list.append ( dict );
|
||||
m_list.push_back ( dict );
|
||||
}
|
||||
|
||||
void QQtDictNode::insertChild ( const QString& key, const QQtDictNode& dict )
|
||||
@ -69,6 +72,7 @@ void QQtDictNode::insertChild ( int index, const QString& value )
|
||||
void QQtDictNode::insertChild ( int index, const QQtDictNode& dict )
|
||||
{
|
||||
m_type = DictList;
|
||||
//list类
|
||||
//insert不能实现max count以后插入。
|
||||
//[]不能实现插入操作,而是实现覆盖操作。
|
||||
//怎么办?
|
||||
@ -247,6 +251,7 @@ const QQtDictNode& QQtDictNode::operator[] ( int index ) const
|
||||
QQtDictNode::QQtDictNode ( const QVariant& value, QObject* parent ) :
|
||||
QObject ( parent )
|
||||
{
|
||||
m_type = DictValue;
|
||||
*this = value;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,13 @@ public:
|
||||
int loopsRemaining() const;
|
||||
void setLoops ( int loops );
|
||||
|
||||
//设置读文件的时钟快慢(硬盘快,时钟快,每次读的少;硬盘慢,时钟慢,每次读的多)
|
||||
//默认使用 macOS SSD 20ms
|
||||
//Windows上,机械硬盘,可能会延迟,可以设置100ms。
|
||||
void setTimerInterval ( int millSecond = 20 ) {
|
||||
mWavInput.setTimerInterval ( millSecond );
|
||||
}
|
||||
|
||||
private slots:
|
||||
void readyRead();
|
||||
|
||||
|
@ -49,8 +49,9 @@ public:
|
||||
//读取用。这个是个内部公用的,并不是临时的。碰巧了。
|
||||
QIODevice* device() { return &mBytesBuffer; }
|
||||
|
||||
//采样间隔 10-100ms default: macOS 20 ms
|
||||
//windows suggest 50ms, windows is slower than macOS.
|
||||
//设置读文件的时钟快慢(硬盘快,时钟快,每次读的少;硬盘慢,时钟慢,每次读的多)
|
||||
//采样间隔 10-100ms default: macOS SSD 20 ms
|
||||
//windows 机械硬盘 100ms, windows 机械硬盘 is slower than macOS SSD.
|
||||
int timerInterval() const { return mTimerInterval; }
|
||||
void setTimerInterval ( int millSecond = 20 );
|
||||
//可以频繁开启,tip:用完一定要关闭,系统会自动关闭。
|
||||
|
@ -3,7 +3,7 @@
|
||||
#这个文件用于指示版权。
|
||||
#-------------------------------------------------------
|
||||
#pluginsupport
|
||||
#DEFINES += __PLUGINSUPPORT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __PLUGINSUPPORT__
|
||||
#TODO: macOS crash
|
||||
contains (DEFINES, __PLUGINSUPPORT__) {
|
||||
contains(QKIT_PRIVATE, WIN32|WIN64) {
|
||||
@ -29,7 +29,7 @@ contains (DEFINES, __PLUGINSUPPORT__) {
|
||||
|
||||
contains(DEFINES, __QQTCHARTS__) {
|
||||
#qcustomplot
|
||||
#DEFINES += __CUSTOMPLOT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __CUSTOMPLOT__
|
||||
contains (DEFINES, __CUSTOMPLOT__) {
|
||||
#message (qcustomplot is used in $${TARGET})
|
||||
win32 {
|
||||
@ -50,7 +50,7 @@ contains(DEFINES, __QQTCHARTS__) {
|
||||
contains (DEFINES, __NETWORKSUPPORT__) {
|
||||
#qextserialport support
|
||||
#if you use qextserialport, open the two annotation
|
||||
#DEFINES += __QEXTSERIALPORT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __QEXTSERIALPORT__
|
||||
contains (DEFINES, __QEXTSERIALPORT__) {
|
||||
#include ( $$PWD/network/qextserialport/qextserialport.pri )
|
||||
HEADERS += $$PWD/network/qextserialport/qextserialbase.h \
|
||||
@ -81,7 +81,7 @@ contains (DEFINES, __NETWORKSUPPORT__) {
|
||||
}
|
||||
|
||||
#gumbo support
|
||||
#DEFINES += __GUMBOSUPPORT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __GUMBOSUPPORT__
|
||||
contains (DEFINES, __GUMBOSUPPORT__) {
|
||||
include ($$PWD/network/gumbo/parser/gumbo-parser.pri)
|
||||
include ($$PWD/network/gumbo/query/gumbo-query.pri)
|
||||
@ -93,7 +93,7 @@ contains (DEFINES, __NETWORKSUPPORT__) {
|
||||
##-------------------------------------------------------
|
||||
contains (DEFINES, __EXQUISITE__) {
|
||||
#qrencode widgets
|
||||
#DEFINES += __QRENCODE__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __QRENCODE__
|
||||
contains (DEFINES, __QRENCODE__) {
|
||||
include ($$PWD/exquisite/qrcode/qrencode/qrencode.pri)
|
||||
|
||||
@ -104,7 +104,7 @@ contains (DEFINES, __EXQUISITE__) {
|
||||
}
|
||||
|
||||
#qrdecode widget
|
||||
#DEFINES += __QRDECODE__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __QRDECODE__
|
||||
contains (DEFINES, __QRDECODE__) {
|
||||
contains(QKIT_PRIVATE, WIN32|WIN64) {
|
||||
#ignore: QZXing has no need to export
|
||||
@ -124,7 +124,7 @@ contains (DEFINES, __EXQUISITE__) {
|
||||
}
|
||||
|
||||
#mathml widget
|
||||
#DEFINES += __MATHSUPPORT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __MATHSUPPORT__
|
||||
contains (DEFINES, __MATHSUPPORT__) {
|
||||
contains(QKIT_PRIVATE, WIN32|WIN64) {
|
||||
#mathml
|
||||
|
@ -181,7 +181,8 @@ contains (DEFINES, __NETWORKSUPPORT__) {
|
||||
#DEFINES += __QEXTSERIALPORT__
|
||||
#if compiler QtSerialPort module manual, note this line is a good idea. default: qt4 qextserialport
|
||||
lessThan(QT_MAJOR_VERSION, 5): DEFINES += __QEXTSERIALPORT__
|
||||
#to ios, use qextserialport #android qt5 support serialport default?
|
||||
#to ios, use qextserialport
|
||||
#android qt5 support serialport default?
|
||||
contains (DEFINES, __IOS__): DEFINES += __QEXTSERIALPORT__
|
||||
contains (DEFINES, __QEXTSERIALPORT__) {
|
||||
CONFIG += thread
|
||||
|
@ -202,7 +202,7 @@ contains (DEFINES, __MULTIMEDIA__) {
|
||||
|
||||
|
||||
#printsupport
|
||||
#DEFINES += __PRINTSUPPORT__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __PRINTSUPPORT__
|
||||
contains (DEFINES, __PRINTSUPPORT__) {
|
||||
SOURCES += $$PWD/printsupport/qqtprinter.cpp
|
||||
HEADERS += $$PWD/printsupport/qqtprinter.h
|
||||
@ -256,7 +256,7 @@ contains (DEFINES, __NETWORKSUPPORT__) {
|
||||
$$PWD/network/qqtserialport.h
|
||||
|
||||
#bluetooth
|
||||
#DEFINES += __BLUETOOTH__
|
||||
#注释:在qqt_header.pri打开 DEFINES += __BLUETOOTH__
|
||||
contains (DEFINES, __BLUETOOTH__) {
|
||||
#bluetooth socket
|
||||
SOURCES += \
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include <QQtApplication>
|
||||
#include <qqtcore.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main ( int argc, char* argv[] )
|
||||
{
|
||||
QQtApplication a(argc, argv);
|
||||
QQtApplication a ( argc, argv );
|
||||
|
||||
MainWindow w;
|
||||
//w.show();
|
||||
|
@ -111,5 +111,38 @@ int main ( int argc, char* argv[] )
|
||||
//Widget w;
|
||||
//w.show();
|
||||
|
||||
//QQtDictNode appendChild函数存在一个问题,
|
||||
//内部实现使用list的append函数,会引用外部的类实例,这导致在free空间的时候,存在很多莫名其妙的二次free,尤其外部实例和QObject关联的时候。
|
||||
//现在内部实现使用push_back,这里检测QQtDictNode还有没有二次free这个bug。
|
||||
QQtDictNode* n0 = new QQtDictNode ( QVariant ( "This is a value" ) );
|
||||
//这里打印一下n0的值和地址
|
||||
pline() << n0->getValue().value<QString>();
|
||||
pline() << hex << n0->getValue().constData();
|
||||
|
||||
QQtDictNode t0;
|
||||
//这里appendChild,t0变成一个list。
|
||||
t0.appendChild ( *n0 );
|
||||
|
||||
//这里更改外部实例的值,显然外部实例的值已经改变了。
|
||||
n0->getValue().setValue<QString> ( "This is a changed value" );
|
||||
|
||||
//为了证实这一点,这里打印值
|
||||
pline() << "外部空间的值" << n0->getValue().value<QString>();
|
||||
//这里可能还有一个疑惑,新的值是不是占据了新的空间?其实,没有。这里打印地址证实。
|
||||
pline() << "外部空间的地址" << hex << n0->getValue().constData();
|
||||
|
||||
//这里删除外部实例n0,不用把n0置零,不必要,n0和申请的存储空间是两回事。
|
||||
delete n0;
|
||||
//但是,置零,规范一点。
|
||||
n0 = NULL;
|
||||
|
||||
//外部的空间的值被改变了,并且删除了,内部空间的值,发生了什么?
|
||||
//现在检查,内部的值是多少?
|
||||
pline() << "检测内部空间的值:" << t0[0].getValue().value<QString>();
|
||||
pline() << "检测内部空间的地址:" << hex << t0[0].getValue().constData() ;
|
||||
|
||||
//windows
|
||||
//经过测试,QQtDictNode内部空间成功和外部空间分离,bug清除。
|
||||
|
||||
return 0;//a.exec();
|
||||
}
|
||||
|
@ -551,5 +551,7 @@ void MainWindow::on_pushButton_11_clicked()
|
||||
void MainWindow::on_pushButton_12_clicked()
|
||||
{
|
||||
//android support 16bit but 24bit
|
||||
QQtWavSoundEffect* e0 = QQtWavSound();
|
||||
e0->setTimerInterval ( 100 );
|
||||
QQtWavSound ( res ( "9767.wav" ) );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user