more reliable recently executed build tracking
This commit is contained in:
parent
52a8b41229
commit
48a6cf3c9e
|
|
@ -324,12 +324,9 @@ Project::iterator Project_find( Project& project, const char* name ){
|
||||||
}
|
}
|
||||||
|
|
||||||
Project::iterator Project_find( Project& project, std::size_t index ){
|
Project::iterator Project_find( Project& project, std::size_t index ){
|
||||||
Project::iterator i = project.begin();
|
return index < project.size()
|
||||||
while ( index-- != 0 && i != project.end() )
|
? std::next( project.begin(), index )
|
||||||
{
|
: project.end();
|
||||||
++i;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Build& project_find( Project& project, const char* build ){
|
Build& project_find( Project& project, const char* build ){
|
||||||
|
|
@ -338,6 +335,13 @@ Build& project_find( Project& project, const char* build ){
|
||||||
return ( *i ).second;
|
return ( *i ).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Project_contains( const Project& project, Project::const_iterator iterator ){
|
||||||
|
for( auto i = project.cbegin(); i != project.cend(); ++i )
|
||||||
|
if( i == iterator )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Build::iterator Build_find( Build& build, std::size_t index ){
|
Build::iterator Build_find( Build& build, std::size_t index ){
|
||||||
Build::iterator i = build.begin();
|
Build::iterator i = build.begin();
|
||||||
while ( index-- != 0 && i != build.end() )
|
while ( index-- != 0 && i != build.end() )
|
||||||
|
|
@ -451,6 +455,7 @@ public:
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
Project g_build_project;
|
Project g_build_project;
|
||||||
|
Project::const_iterator g_lastExecutedBuild;
|
||||||
Tools g_build_tools;
|
Tools g_build_tools;
|
||||||
bool g_build_changed = false;
|
bool g_build_changed = false;
|
||||||
}
|
}
|
||||||
|
|
@ -486,6 +491,7 @@ void build_run( const char* name, CommandListener& listener ){
|
||||||
{
|
{
|
||||||
Project::iterator i = Project_find( g_build_project, name );
|
Project::iterator i = Project_find( g_build_project, name );
|
||||||
if ( i != g_build_project.end() ) {
|
if ( i != g_build_project.end() ) {
|
||||||
|
g_lastExecutedBuild = i;
|
||||||
Build& build = ( *i ).second;
|
Build& build = ( *i ).second;
|
||||||
for ( Build::iterator j = build.begin(); j != build.end(); ++j )
|
for ( Build::iterator j = build.begin(); j != build.end(); ++j )
|
||||||
{
|
{
|
||||||
|
|
@ -948,12 +954,16 @@ void LoadBuildMenu();
|
||||||
void DoBuildMenu(){
|
void DoBuildMenu(){
|
||||||
ProjectList projectList( g_build_project );
|
ProjectList projectList( g_build_project );
|
||||||
const Project bakproj = g_build_project;
|
const Project bakproj = g_build_project;
|
||||||
|
const size_t baklast = Project_contains( g_build_project, g_lastExecutedBuild )
|
||||||
|
? std::distance( g_build_project.cbegin(), g_lastExecutedBuild )
|
||||||
|
: 0;
|
||||||
|
|
||||||
const EMessageBoxReturn ret = BuildMenuDialog_construct( projectList );
|
const EMessageBoxReturn ret = BuildMenuDialog_construct( projectList );
|
||||||
|
|
||||||
if ( ret == eIDCANCEL || ret == 0 ) {
|
if ( ret == eIDCANCEL || ret == 0 ) {
|
||||||
if ( projectList.m_changed || g_build_changed ){
|
if ( projectList.m_changed || g_build_changed ){
|
||||||
g_build_project = bakproj;
|
g_build_project = bakproj;
|
||||||
|
g_lastExecutedBuild = std::next( g_build_project.cbegin(), baklast );
|
||||||
Build_refreshMenu( g_bsp_menu );
|
Build_refreshMenu( g_bsp_menu );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -974,8 +984,6 @@ void DoBuildMenu(){
|
||||||
#include "mainframe.h"
|
#include "mainframe.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
class BuildMenuItem *g_lastExecutedBuild = nullptr;
|
|
||||||
|
|
||||||
class BuildMenuItem
|
class BuildMenuItem
|
||||||
{
|
{
|
||||||
const char* m_name;
|
const char* m_name;
|
||||||
|
|
@ -984,11 +992,10 @@ public:
|
||||||
BuildMenuItem( const char* name, QAction* item )
|
BuildMenuItem( const char* name, QAction* item )
|
||||||
: m_name( name ), m_item( item ){
|
: m_name( name ), m_item( item ){
|
||||||
}
|
}
|
||||||
void run(){
|
void run() const {
|
||||||
g_lastExecutedBuild = this;
|
|
||||||
RunBSP( m_name );
|
RunBSP( m_name );
|
||||||
}
|
}
|
||||||
typedef MemberCaller<BuildMenuItem, &BuildMenuItem::run> RunCaller;
|
typedef ConstMemberCaller<BuildMenuItem, &BuildMenuItem::run> RunCaller;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::list<BuildMenuItem> BuildMenuItems;
|
typedef std::list<BuildMenuItem> BuildMenuItems;
|
||||||
|
|
@ -1087,11 +1094,8 @@ void BuildMenu_Destroy(){
|
||||||
|
|
||||||
|
|
||||||
void Build_runRecentExecutedBuild(){
|
void Build_runRecentExecutedBuild(){
|
||||||
if( std::any_of( g_BuildMenuItems.cbegin(), g_BuildMenuItems.cend(), []( const BuildMenuItem& item ){ return g_lastExecutedBuild == &item; } ) ){
|
if( Project_contains( g_build_project, g_lastExecutedBuild ) )
|
||||||
g_lastExecutedBuild->run();
|
RunBSP( g_lastExecutedBuild->first.c_str() );
|
||||||
}
|
else if( !g_build_project.empty() )
|
||||||
else{
|
RunBSP( g_build_project.cbegin()->first.c_str() );
|
||||||
if( !g_BuildMenuItems.empty() )
|
|
||||||
g_BuildMenuItems.begin()->run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user