Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31

Thread: unzip and untar into new directory

  1. #21
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: unzip and untar into new directory

    Ah ok, well I saw it used the way I was trying to use it in an example but apparently that example was incorrect. Just so I am clear the reason it doesn't work is because the connection is made but then shortly after the connection is made the object falls out of scope and thus is destroyed before anything can ever happen? I think I am right on this but just want to make sure. So I was able to get the extraction working properly but when I try and use another process to re-archive it using peazip it works but after about 3 minutes it just kills the process while it is still running. Any idea what would cause that? I will post the relevant code if necessary but thought I would get a general idea of what might be causing the process to stop while running. Thanks again for any help and all the help that has come thus far.
    Last edited by jshafferman; 25th July 2012 at 16:33.

  2. #22
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: unzip and untar into new directory

    "after the connection is made the object falls out of scope and thus is destroyed before anything can ever happen?"
    Yes.

    "So I was able to get the extraction working properly but when I try and use another process to re-archive it using peazip it works but after about 3 minutes it just kills the process while it is still running. Any idea what would cause that?"
    If you are suggesting that peazip kills your app, then I think that is unlikely. If your app dies after three minutes then you need to start debugging your app. If you mean that the peazip process is killed, then maybe it is just from a timeout in QProcess? Is 3 minutes a reasonable time for the process to take? Probably not (sounds too long) so maybe something has gone wrong with your archive command.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #23
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: unzip and untar into new directory

    I don't think QProcess has any timeouts. That would not be very logical. There is a timeout in QProcess::waitForFinished() but it wouldn't kill the child process, just would timeout the suspension of the parent process.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #24
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: unzip and untar into new directory

    What happens is the process starts and brings up the peazip GUI for archiving the file. I think it is roughly about 2-3 minutes later when the peazip GUI closes out and I get the following message in the debugger: QProcess: Destroyed while process is still running.

    Here is the code segment
    Qt Code:
    1. bool MainWindow::saveFile(const QString &fileName)
    2. {
    3. // file manipulation...
    4.  
    5. QDir dir(directory);
    6.  
    7. QProcess tar(this);
    8. QStringList arguments;
    9. arguments << "-add2archive" << dir.path();
    10. tar.start("peazip", arguments);
    11.  
    12. if(tar.waitForFinished())
    13. tar.close();
    14.  
    15. // reset some toggle values and return true
    16. }
    To copy to clipboard, switch view to plain text mode 

    I am simply curious what would cause the peazip GUI to crash/close. Thanks for any help!

  5. #25
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: unzip and untar into new directory

    Quoting the docs for QProcess::close():

    Closes all communication with the process and kills it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #26
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: unzip and untar into new directory

    If I take out the if(tar.waitForFinished()) statement then the application immediately gives me the same debug error. If I take out the tar.close() statement inside of the if statement then it allows the application to open and then crashes/closes after 2-3 minutes still. Is there a way to make the process wait until I have finished using the application? I thought it was waitForFinsihed() but that doesn't appear to be the case.

  7. #27
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: unzip and untar into new directory

    Did you carefully read the docs for waitForFinished() before using that method?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #28
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: unzip and untar into new directory

    I thought I had understood it. I did read it again a few times just to see if I misunderstood what I had initially read. It appears that the waitForFinish() is not well suited for GUI application (according to the documentation) however I don't see any other function that would allow me to wait for a boolean statement to signal that the process has finished correctly. The documentaiton mentions something about an event loop but I haven't been able to see any examples or functions I could use to run an event loop waiting for the process (peazip archiving) to be finished. How would I go about doing this? My guess is to use a while loop and wait for the state() function to return NotRunning... Am I on the right track with that?

  9. #29
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: unzip and untar into new directory

    yeah, we have both (wysota and I) mentioned timeout - why haven't you tried waitForfinished(-1) or waitForfinished(300000), say?
    Have you tried running the zip util from the command line with the same arguments? does it work ok?

    How would I go about doing this? My guess is to use a while loop and wait for the state() function to return NotRunning... Am I on the right track with that?
    No.
    rtfm already!
    Last edited by amleto; 26th July 2012 at 19:01.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  10. #30
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: unzip and untar into new directory

    Grrr... I did know about the msec parameter that you can optionally put in the waitForFinished() but I didn't want it to timeout until the user was done. After seeing your post I read through it again and I released I was glazing over one of the most important parts of the waitForFinished() parameter -1. I assumed that if I put -1 it wouldn't ever close the peazip process because the documentation said it would never timeout but I realize now that just meant the QProcess itself not the application it is using. So basically if I put -1 in for the waitForFinish() it waits until I click the ok button on the peazip, archives the files, and then the application closes out. Since the QProcess is built on the stack, I am assuming that as soon as the program exits the scope of that function the QProcess is destroyed. This will work perfectly for me and I want to say thanks to both of you for helping me figure it out and especially since you let me get there partially on my own .

    Thanks I think I have it working properly now!

  11. #31
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: unzip and untar into new directory

    glad that you seemed to have blasted all the gremlins, and also that you appreciate that (in the long run) the more you figure out for yourself, the easier things will be for you.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. How to Zip/Unzip with QT for symbian???
    By baka3k in forum Newbie
    Replies: 2
    Last Post: 22nd June 2011, 08:24
  2. No such file or directory
    By Bertbeeg in forum Newbie
    Replies: 4
    Last Post: 24th October 2010, 23:04
  3. get .pro directory
    By Alnitak in forum Qt Programming
    Replies: 5
    Last Post: 14th October 2010, 18:43
  4. Specify the DLL directory
    By Nyphel in forum Newbie
    Replies: 6
    Last Post: 27th April 2007, 14:29
  5. OpenOffice file to QTextEdit (Unzip Problem)
    By patrik08 in forum Qt Programming
    Replies: 6
    Last Post: 27th November 2006, 10:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.