ilia3101 / MLV-App

All in one MLV processing app.
https://mlv.app/
GNU General Public License v3.0
274 stars 30 forks source link

MLV App gets in to infinite loop of dialogs when encountering empty files. #241

Closed ilia3101 closed 2 years ago

ilia3101 commented 2 years ago

Try opening this file at the same time as opening other files (selecting a few in finder, and opening all at once), I don't know why I have files like this but I'm finding them in various places:

M02-1622.MLV.zip

I think this bug also happens when a file gets deleted or moved on disk but is still in the session and you try to click on it again in the session.

Probably the same control flow issue causes all these infinite loops?

masc4ii commented 2 years ago

For me there is no infinite loop.

  1. MLVApp tells the file has no frames.
  2. MLVApp asks to remove the file from session (remove, delete, abort)
  3. When removing or deleting the problem is gone. When aborting: MLVApp tells again once "no frames" when trying to load the file. You can remove the file manually.
ilia3101 commented 2 years ago

Did you try opening it along with another file?

Here, I select two files, one is this file, the other is just a random MLV without issues (from a different day and a different camera, can be anything), and I try to open them both at the same time:

https://user-images.githubusercontent.com/23642861/162452365-8deab69f-9e73-42fd-81c3-1c87676282b0.mov

I'm using MLV App 1.13 official release for macos.

masc4ii commented 2 years ago

Okay. I see. The problem comes to life with minimum 2 invalid clips. It happens in MainWindow.cpp:

int MainWindow::showFileInEditor(int row)
{
    if( SESSION_CLIP_COUNT <= 0 ) return 1;

    //Stop Playback
    ui->actionPlay->setChecked( false );
    //Save slider receipt
    if( !ACTIVE_RECEIPT->wasNeverLoaded() && !m_inClipDeleteProcess ) setReceipt( ACTIVE_RECEIPT );
    //Save new position in session
    int oldActive = SESSION_ACTIVE_CLIP_ROW;
    SET_ACTIVE_CLIP_IDX( row );
    //Open new MLV
    if( openMlv( GET_CLIP( row )->getPath() ) )
    {
        //If one file is selected, reselect the last one, else do nothing (export)
        //And if there is another file we can switch to...
        if( selectedClipsList().count() <= 1
         && SESSION_CLIP_COUNT > 1)
        {
            m_pSelectionModel->setCurrentIndex( m_pProxyModel->mapFromSource( m_pModel->index( oldActive, 0, QModelIndex() ) ), QItemSelectionModel::ClearAndSelect );
            showFileInEditor( oldActive );
        }
        return 1;
    }

oldActive should be loaded by showFileInEditor function and becomes recursive, if a 2nd file is also invalid. We should save somehow, if a clip was loaded successfully at least once before - if not we should stop this behavior.

masc4ii commented 2 years ago

Could you try this please? 5c6a87cb49bb49d83bba1be28851831d7ea7865d For me this stops the loop after a few messages. But removing files still just works when importing one invalid file. The algorithm seems to fail if no valid file opened and still importing more invalid files.

ilia3101 commented 2 years ago

Thanks for the fix, will try this out. Reporting back soon.

ilia3101 commented 2 years ago

Can confirm, no more infinte loop. The window appears a couple of times.

ilia3101 commented 2 years ago

I think this can be closed, as my core issue is fixed.