From ef2a79e804484f53e4e627393b390ee53dc6a0cf Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Sun, 4 Nov 2007 04:56:31 +0000 Subject: [PATCH] serious bug fixes in search bar. think some could still exist git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@648 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/PresetLoader.cpp | 2 +- src/projectM-engine/projectM.cpp | 25 ++++++++++++++++------ src/qprojectM/src/QProjectM_MainWindow.cpp | 2 ++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/projectM-engine/PresetLoader.cpp b/src/projectM-engine/PresetLoader.cpp index ffbae7e17..8b3fc63e3 100644 --- a/src/projectM-engine/PresetLoader.cpp +++ b/src/projectM-engine/PresetLoader.cpp @@ -120,7 +120,7 @@ std::auto_ptr PresetLoader::loadPreset(unsigned int index, const PresetI assert(index >= 0); assert(index < m_entries.size()); - // Return a new autopointer to a present + // Return a new autopointer to a preset return std::auto_ptr(new Preset(m_entries[index], m_presetNames[index], presetInputs, presetOutputs)); } diff --git a/src/projectM-engine/projectM.cpp b/src/projectM-engine/projectM.cpp index 1030ff654..bb8df4a12 100755 --- a/src/projectM-engine/projectM.cpp +++ b/src/projectM-engine/projectM.cpp @@ -69,7 +69,7 @@ double smoothDuration = 5; //int smoothFrame = 0; int oldFrame = 1; -DLLEXPORT projectM::projectM ( int gx, int gy, int fps, int texsize, int width, int height, std::string preset_url,std::string title_fonturl, std::string title_menuurl ) :beatDetect ( 0 ), renderer ( 0 ), presetURL ( preset_url ), title_fontURL ( title_fonturl ), menu_fontURL ( menu_fontURL ), smoothFrame ( 0 ) +DLLEXPORT projectM::projectM ( int gx, int gy, int fps, int texsize, int width, int height, std::string preset_url,std::string title_fonturl, std::string title_menuurl ) :beatDetect ( 0 ), renderer ( 0 ), presetURL ( preset_url ), title_fontURL ( title_fonturl ), menu_fontURL ( menu_fontURL ), smoothFrame ( 0 ), m_presetQueuePos(0) { presetURL = preset_url; projectM_reset(); @@ -101,7 +101,7 @@ DLLEXPORT void projectM::projectM_resetTextures() } DLLEXPORT projectM::projectM ( std::string config_file ) : - beatDetect ( 0 ), renderer ( 0 ), smoothFrame ( 0 ) + beatDetect ( 0 ), renderer ( 0 ), smoothFrame ( 0 ),m_presetQueuePos(0) { projectM_reset(); @@ -791,10 +791,10 @@ int projectM::initPresetTools() m_presetPos = new PresetIterator(); // Initialize a preset queue position as well - m_presetQueuePos = new PresetIterator(); +// m_presetQueuePos = new PresetIterator(); // Start at end ptr- this allows next/previous to easily be done from this position. - *m_presetPos = *m_presetQueuePos = m_presetChooser->end(); + *m_presetPos = m_presetChooser->end(); // Load idle preset //std::cerr << "[projectM] Allocating idle preset..." << std::endl; @@ -851,7 +851,11 @@ void projectM::destroyPresetTools() void projectM::removePreset(unsigned int index) { + + + m_presetLoader->removePreset(index); + } unsigned int projectM::addPresetURL ( const std::string & presetURL, const std::string & presetName ) @@ -882,13 +886,15 @@ void projectM::switchPreset(std::auto_ptr & targetPreset, const PresetIn // If queue not specified, roll with usual random behavior - if (*m_presetQueuePos == m_presetChooser->end()) { + if (m_presetQueuePos == 0) { *m_presetPos = m_presetChooser->weightedRandom(); targetPreset = m_presetPos->allocate( inputs, outputs ); } else { // queue item specified- use it and reset the queue + abort(); targetPreset = m_presetQueuePos->allocate ( inputs, outputs ); - *m_presetQueuePos = m_presetChooser->end(); + delete(m_presetQueuePos); + m_presetQueuePos = 0; } // Set preset name here- event is not done because at the moment this function is oblivious to smooth/hard switches @@ -920,11 +926,16 @@ std::string projectM::getPresetName ( unsigned int index ) const void projectM::clearPlaylist ( ) { m_presetLoader->clear(); - *m_presetQueuePos = m_presetChooser->end(); + delete(m_presetQueuePos); + m_presetQueuePos = 0; } void projectM::queuePreset(unsigned int index) { + + if (m_presetQueuePos == 0) + m_presetQueuePos = new PresetIterator(); + if ((index >= 0) && (index <= m_presetChooser->getNumPresets())) *m_presetQueuePos = m_presetChooser->begin(index); } diff --git a/src/qprojectM/src/QProjectM_MainWindow.cpp b/src/qprojectM/src/QProjectM_MainWindow.cpp index 4c583fa65..62022f936 100644 --- a/src/qprojectM/src/QProjectM_MainWindow.cpp +++ b/src/qprojectM/src/QProjectM_MainWindow.cpp @@ -127,6 +127,8 @@ void QProjectM_MainWindow::keyReleaseEvent ( QKeyEvent * e ) { //m_QProjectMWidget->keyReleaseEvent(e); return; + case Qt::Key_F1: + //emit(keyPressed m_QProjectMWidget, case Qt::Key_F: if (ui.presetSearchBarLineEdit->hasFocus()) return;