Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Program works on Linux but not on OSX
QtWS25 Last Chance

Program works on Linux but not on OSX

Scheduled Pinned Locked Moved General and Desktop
taglibosxlinux
11 Posts 3 Posters 4.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devbrs
    wrote on 15 Mar 2015, 23:59 last edited by devbrs
    #1

    I have a program that is similar to a music library. It loads a folder and gets the tags from the mp3 file and list it in a MainWindow using taglib.

    This is a snipet of the code that gets the tags

    	TagLib::FileRef f(list[PATH].toAscii());
    
    	TagLib::Tag *tag = f.tag();
    
        list.replace(TITLE , QString::fromStdString8(tag->title().to8Bit()));
    	list.replace(TIME , "Not Yet");
        list.replace(ARTIST , QString::fromStdString(tag->artist().to8Bit()));
        list.replace(ALBUM , QString::fromStdString(tag->album().to8Bit()));
        list.replace(GENRE , QString::fromStdString(tag->genre().to8Bit()));
    
        std::ostringstream oss;
        oss << tag->track();
    
        list.replace(TRACK , QString::fromStdString(oss.str().c_str()));
    

    My friend used this on ubuntu linux and it worked, he can load a folder and get the mp3 tags. However, when I try to do it on OSX, the program runs, but when I try to load a folder, the program crashes. When I comment out these few lines, I can load the folder but, obviously I won't get the tags. My Qt uses the OSX clang compiler, not sure if that's a factor...

        //list.replace(TITLE , QString::fromStdString8(tag->title().to8Bit()));
    	list.replace(TIME , "Not Yet");
        //list.replace(ARTIST , QString::fromStdString(tag->artist().to8Bit()));
        //list.replace(ALBUM , QString::fromStdString(tag->album().to8Bit()));
        //list.replace(GENRE , QString::fromStdString(tag->genre().to8Bit()));
    
    M 1 Reply Last reply 17 Mar 2015, 00:26
    0
    • M Offline
      M Offline
      mcosta
      wrote on 16 Mar 2015, 00:07 last edited by
      #2

      Seems a crash inside TagLib; do you have the crash dump?

      Anyway I think you should check the value of tag

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      D 1 Reply Last reply 16 Mar 2015, 00:15
      0
      • M mcosta
        16 Mar 2015, 00:07

        Seems a crash inside TagLib; do you have the crash dump?

        Anyway I think you should check the value of tag

        D Offline
        D Offline
        devbrs
        wrote on 16 Mar 2015, 00:15 last edited by
        #3

        @mcosta How do you check crash dump or the value of tag? I'm not very experienced in this. I'm using Qt creator and it simply says "The program has unexpectedly finished."

        1 Reply Last reply
        0
        • D Offline
          D Offline
          devbrs
          wrote on 16 Mar 2015, 00:26 last edited by
          #4

          When I open osx's crash report, I get this, but I'm not sure if this is actually useful... https://www.dropbox.com/s/8c3vpsg6jzjkc2j/423432.txt?dl=0

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mcosta
            wrote on 16 Mar 2015, 00:36 last edited by
            #5

            The dump says that the std::string::size() generated the crash.

            I think you should DEBUG the TagLib code

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dyami Caliri
              wrote on 16 Mar 2015, 21:16 last edited by
              #6

              I doubt the problem is with TagLib.

              From the description, and the way you've fixed it (temporarily), it's almost definitely that f.tag() is returning NULL. So you have not constructed your FileRef correctly, meaning that the path is not correct, or not the proper form, or FileRef somehow wasn't able to parse it.

              In any case, your code should always be checking tag before using it. That will fix the crash. Then figure out why the path you passed in to the constructor didn't work.

              D 1 Reply Last reply 17 Mar 2015, 00:24
              0
              • D Dyami Caliri
                16 Mar 2015, 21:16

                I doubt the problem is with TagLib.

                From the description, and the way you've fixed it (temporarily), it's almost definitely that f.tag() is returning NULL. So you have not constructed your FileRef correctly, meaning that the path is not correct, or not the proper form, or FileRef somehow wasn't able to parse it.

                In any case, your code should always be checking tag before using it. That will fix the crash. Then figure out why the path you passed in to the constructor didn't work.

                D Offline
                D Offline
                devbrs
                wrote on 17 Mar 2015, 00:24 last edited by
                #7

                @Dyami-Caliri I have finally got my ubuntu virtualbox working, and the program is working fine on there. So I think I will just stick to ubuntu for now. Although I still don't understand why it works on Linux but not on OsX when I'm using the same exact code.

                D 1 Reply Last reply 17 Mar 2015, 16:46
                0
                • D devbrs
                  15 Mar 2015, 23:59

                  I have a program that is similar to a music library. It loads a folder and gets the tags from the mp3 file and list it in a MainWindow using taglib.

                  This is a snipet of the code that gets the tags

                  	TagLib::FileRef f(list[PATH].toAscii());
                  
                  	TagLib::Tag *tag = f.tag();
                  
                      list.replace(TITLE , QString::fromStdString8(tag->title().to8Bit()));
                  	list.replace(TIME , "Not Yet");
                      list.replace(ARTIST , QString::fromStdString(tag->artist().to8Bit()));
                      list.replace(ALBUM , QString::fromStdString(tag->album().to8Bit()));
                      list.replace(GENRE , QString::fromStdString(tag->genre().to8Bit()));
                  
                      std::ostringstream oss;
                      oss << tag->track();
                  
                      list.replace(TRACK , QString::fromStdString(oss.str().c_str()));
                  

                  My friend used this on ubuntu linux and it worked, he can load a folder and get the mp3 tags. However, when I try to do it on OSX, the program runs, but when I try to load a folder, the program crashes. When I comment out these few lines, I can load the folder but, obviously I won't get the tags. My Qt uses the OSX clang compiler, not sure if that's a factor...

                      //list.replace(TITLE , QString::fromStdString8(tag->title().to8Bit()));
                  	list.replace(TIME , "Not Yet");
                      //list.replace(ARTIST , QString::fromStdString(tag->artist().to8Bit()));
                      //list.replace(ALBUM , QString::fromStdString(tag->album().to8Bit()));
                      //list.replace(GENRE , QString::fromStdString(tag->genre().to8Bit()));
                  
                  M Offline
                  M Offline
                  mcosta
                  wrote on 17 Mar 2015, 00:26 last edited by
                  #8

                  @devbrs said:

                  TagLib::FileRef f(list[PATH].toAscii());

                  What is list?? Could be a conflict with std::list??

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  1 Reply Last reply
                  0
                  • D devbrs
                    17 Mar 2015, 00:24

                    @Dyami-Caliri I have finally got my ubuntu virtualbox working, and the program is working fine on there. So I think I will just stick to ubuntu for now. Although I still don't understand why it works on Linux but not on OsX when I'm using the same exact code.

                    D Offline
                    D Offline
                    Dyami Caliri
                    wrote on 17 Mar 2015, 16:46 last edited by
                    #9

                    @devbrs The most likely cause is that the path you use on the Mac has non-ASCII characters in it. If that's the case, you would need to use UTF8 instead of ASCII. I don't know what type list is, so I don't know what method you need, but I'm guessing toUTF8().

                    There could be other things wrong with the code, that happen to work on Linux but don't work on OSX. For example, PATH as an index seems fairly odd. But you haven't given us the rest of the relevant code.

                    If the path doesn't have non-ASCII characters in it, maybe you should post more of your code.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      devbrs
                      wrote on 18 Mar 2015, 00:09 last edited by devbrs
                      #10

                      Here is the code + some other files included in the project
                      qtunes

                      The main code is in MainWindow.cpp, my professor gave us the code, it's basically a Music Library/Player, kind of like iTunes, but we had to implement TagLib to read the mp3 tags. The code isn't very clean sorry.

                      D 1 Reply Last reply 19 Mar 2015, 21:03
                      0
                      • D devbrs
                        18 Mar 2015, 00:09

                        Here is the code + some other files included in the project
                        qtunes

                        The main code is in MainWindow.cpp, my professor gave us the code, it's basically a Music Library/Player, kind of like iTunes, but we had to implement TagLib to read the mp3 tags. The code isn't very clean sorry.

                        D Offline
                        D Offline
                        Dyami Caliri
                        wrote on 19 Mar 2015, 21:03 last edited by
                        #11

                        @devbrs You certainly must check if taglib is null. And you must use toUTF8() instead of toAscii().

                        The last problem is that some of the string conversion functions in TagLib don't appear to work with the QString conversion functions.

                        Namely the functions that create c++ string and wstring objects:

                        QString::fromStdString(tag->title().to8Bit());
                        QString::fromStdWString(tag->title().toWString());
                        

                        The functions that return c style string pointers do work:

                        QString::fromWCharArray(tag->title().toCWString());
                        QString(tag->title().toCString(true));
                        

                        Now, why the string functions work on Linux and not on the Mac, I don't know. Perhaps you could delve into it.

                        1 Reply Last reply
                        0

                        1/11

                        15 Mar 2015, 23:59

                        • Login

                        • Login or register to search.
                        1 out of 11
                        • First post
                          1/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved