[Solved, Moved] More memory needed?



  • @

    musica2::musica2(QWidget *parent) :
    QWidget(parent)
    {
    listafilemusicali = this->searchMusics();
    view = new QDeclarativeView(this);
    view->rootContext()->setContextProperty("listaCanzoni", QVariant::fromValue(this->getSongTitle(listafilemusicali)));
    view->setSource(QUrl::fromLocalFile("qml/Werfer/FliegendeLieder/musica2.qml"));
    this->setAttribute(Qt::WA_LockLandscapeOrientation);

    QObject *b = view->rootObject();
    b->setProperty("lunghezza", QApplication::desktop()->geometry().width());
    b->setProperty("altezza", QApplication::desktop()->geometry().height());
    
    connect(b, SIGNAL(request_close()), this, SLOT(openPrima()));
    connect(b, SIGNAL(request_plauseOrPlay()), this, SLOT(pauseOrPlay_media()));
    connect(b, SIGNAL(request_changeMedia()), this, SLOT(changeMedia()));
    connect(b, SIGNAL(request_hide()), this, SLOT(openWerfer()));
    
    playlist = new QMediaPlaylist();
    playlist->setPlaybackMode(QMediaPlaylist::Random);
    for(int i = 0; i < listafilemusicali.length(); i++)
        playlist->addMedia(QUrl(listafilemusicali.at(i)));
    mediaplayer = new QMediaPlayer();
    mediaplayer->setPlaylist(playlist);
    mediaplayer->play();
    
    b->setProperty("titolo", mediaplayer->media().canonicalUrl().toString().section("/", -1).toLower().replace(".mp3", ""));
    
    view->show();
    this->showFullScreen();
    

    }

    QStringList musica2::searchMusics()
    {
    QStringList listaFileMusicali, listaFolders, listaGenerale;
    listaFolders << "E:/Attachments"; //"C:/Users/7-Spode/Music";
    register int j = 0;
    QDir dir(listaFolders.at(j));
    #ifdef Q_OS_SYMBIAN
    listaGenerale = dir.entryList();
    while (j < listaGenerale.length())
    {
    if(listaGenerale.at(j).contains(".mp3"))
    listaFileMusicali.append("E:/Attachments/" + listaGenerale.at(j));
    qDebug()<<listaFileMusicali.at(j);
    j++;
    }
    return listaFileMusicali;
    #endif
    }
    @

    and the problem is:
    @
    Executable file: 49780 2012-01-14T17:16:41 C:\QtSDK\Symbian\SDKs\Symbian1Qt473\epoc32\release\gcce\udeb\Werfer.exe
    Connecting to 'COM9'...
    Connected.
    Launching: Werfer.exe
    Launched.
    [Qt Message] "01 - An Deiner Seite (Radio Version) - Unheilig.mp3"
    [Qt Message] "012-peter_fox_-alles_neu-ministry.mp3"
    [Qt Message] "12-peter_fox
    -zucker(feat._vanessa_mason)-ysp.mp3"
    [Qt Message] "153 andrea bocheli & laura pausini - vivo por ella.mp3"
    [Qt Message] "21 guns.mp3"
    [Qt Message] "21st Century Breakdown.mp3"
    [Qt Message] ASSERT failure in QList<T>::at: "index out of range", file /QtSDK/Symbian/SDKs/Symbian1Qt473/include/QtCore/qlist.h, line 456
    Thread has crashed: Thread 0x201 has panicked. Category: ASSERT failure i; Reason: 0
    The device 'Nokia C5-03 USB Serial Port (COM9)' has been disconnected.
    @

    that is why i am thinking that my app needs more memory. is it right? how to fix it?



  • No, it is probably just an off by one error in you accessing your QList.



  • @
    while (j < listaGenerale.length())
    {
    if(listaGenerale.at(j).contains(".mp3"))
    listaFileMusicali.append("E:/Attachments/" + listaGenerale.at(j));
    qDebug()<<listaFileMusicali.at(j); // think about this line, especially when
    // listaGenerale.at(j).contains(".mp3") is false
    j++;
    }
    @

    What makes you think that "index out of range" does indicate a insufficient memory problem, and not an out of range index?



  • nothing:
    @
    listaGenerale = dir.entryList();
    while (j < listaGenerale.length())
    {
    if(listaGenerale.at(j).contains(".mp3"))
    {
    listaFileMusicali.append(listaGenerale.at(j));
    qDebug()<<listaFileMusicali.at(j);
    }
    j++;
    }
    @

    @
    Launched.
    [Qt Message] "01 - An Deiner Seite (Radio Version) - Unheilig.mp3"
    [Qt Message] "012-peter_fox_-alles_neu-ministry.mp3"
    [Qt Message] "12-peter_fox
    -zucker(feat._vanessa_mason)-ysp.mp3"
    [Qt Message] "153 andrea bocheli & laura pausini - vivo por ella.mp3"
    [Qt Message] "21 guns.mp3"
    [Qt Message] "21st Century Breakdown.mp3"
    [Qt Message] ASSERT failure in QList<T>::at: "index out of range", file /QtSDK/Symbian/SDKs/Symbian1Qt473/include/QtCore/qlist.h, line 456
    Thread has crashed: Thread 0x20c has panicked. Category: ASSERT failure i; Reason: 0
    The device 'Nokia C5-03 USB Serial Port (COM9)' has been disconnected.
    @

    and in fact next file does not contain ".mp3"


  • Moderators

    By all means it is not a good idea to use the same index j for different things. And that is what you are doing. If you have a list with 10 elements and you copy five of them into another list, how many elements will have you in the list?

    This should work
    @
    listaGenerale = dir.entryList();
    while (j < listaGenerale.length())
    {
    if(listaGenerale.at(j).contains(".mp3"))
    {
    listaFileMusicali.append(listaGenerale.at(j));
    qDebug()<<listaGenerale.at(j);
    }
    j++;
    }
    @



  • that is perfect! =) but do you know, you copied my code? =P


  • Moderators

    Yes, I did copy your code from the post above my post. Hope it does not create a copyright issue :D

    However, you might want to have a close look for the important modification I did.



  • ahahah! =D

    @

    listaGenerale = dir.entryList();
    while (j < listaGenerale.length())
    {
    if(listaGenerale.at(j).contains(".mp3"))
    {
    listaFileMusicali.append(listaGenerale.at(j));
    qDebug()<<listaGenerale.at(j);
    }
    j++;
    }
    @
    i hope it is right! ;)

    EDIT: Damn, it is not right. it persists to throw the same error: [Qt Message] ASSERT failure in QList<T>::at: "index out of range", file /QtSDK/Symbian/SDKs/Symbian1Qt473/include/QtCore/qlist.h, line 456 (working on symbian)


  • Moderators

    Hope you still have this statement as in your original post
    @
    register int j = 0;
    @
    respectively you might want to leave out the register statement and write
    @
    int j = 0;
    @



  • all right now. the problem was the increase of a variable!



  • Best way to solve these issues: make sure that you know the relevant values. Just step through the procedure with your debugger, and watch what happens. Or, perhaps just insert a bunch of qDebug() statements to print out the values of everything you touch in that piece of code. I think it would have been very easy to track this issue this way.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.