Skip to content
  • Oleg Solovyov's avatar
    Fix stack overflow · 18c8b7d5
    Oleg Solovyov authored and Albert Astals Cid's avatar Albert Astals Cid committed
    We get an infinite recursion when we perform search with no files found.
    See below:
    
    void FileSearchTab::performSearch()
    {
        if (m_searchFileListView->files().isEmpty()) { // <= assume true
            addFilesToSearch(doScanRecursive(QDir(Project::instance()->poDir()))); // <= arg is an empty list
    	if (m_searchFileListView->files().isEmpty()) // <= unreachable, see below
    	[...]
    }
    
    void FileSearchTab::addFilesToSearch(const QStringList& files)
    {
        m_searchFileListView->addFiles(files); // <= files.isEmpty() == true
        performSearch(); // <= m_searchFileListView->files().isEmpty() == true
    }
    
    Steps to reproduce:
    1) Project -> Create software translation project -> Save
    2) RMB -> Search in files
    3) Wait ~1 minute until crash
    
    (cherry picked from commit 9b82f864)
    18c8b7d5