Skip to content

Commit

Permalink
Fix debugger plugin reload.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Jan 13, 2025
1 parent fb3b866 commit 0e5337d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/eepp/scene/scenenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void SceneNode::checkClose() {
mCloseList.clear();

for ( Node* node : closeListCopy )
eeDelete( node );
eeSAFE_DELETE( node );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/ecode/ecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void App::onPluginEnabled( Plugin* plugin ) {

void App::initPluginManager() {
mPluginManager = std::make_unique<PluginManager>(
mResPath, mPluginsPath, mThreadPool,
mResPath, mPluginsPath, mConfigPath, mThreadPool,
[this]( const std::string& path, const auto& cb ) {
UITab* tab = mSplitter->isDocumentOpen( path );
if ( !tab ) {
Expand Down
23 changes: 17 additions & 6 deletions src/tools/ecode/plugins/debugger/debuggerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ DebuggerPlugin::~DebuggerPlugin() {
waitUntilLoaded();
mShuttingDown = true;

if ( mSidePanel && mTab )
mSidePanel->removeTab( mTab );
if ( mSidePanel && mTab ) {
if ( Engine::isRunninMainThread() )
mSidePanel->removeTab( mTab );
else {
auto sidePanel = mSidePanel;
auto tab = mTab;
mSidePanel->runOnMainThread( [sidePanel, tab] { sidePanel->removeTab( tab ); } );
}
}

if ( getPluginContext()->getStatusBar() )
getPluginContext()->getStatusBar()->removeStatusBarElement( "status_app_debugger" );
Expand Down Expand Up @@ -619,6 +626,7 @@ void DebuggerPlugin::buildSidePanelTab() {

mUIDebuggerList->on( Event::OnValueChange, [this]( const Event* event ) {
mCurDebugger = event->getNode()->asType<UIDropDownList>()->getText().toUtf8();
mCurConfiguration = "";
} );

mUIDebuggerConfList->on( Event::OnValueChange, [this]( const Event* event ) {
Expand Down Expand Up @@ -667,8 +675,9 @@ void DebuggerPlugin::buildSidePanelTab() {
void DebuggerPlugin::updateSelectedDebugConfig() {
if ( mUIDebuggerList && mUIDebuggerConfList && !mCurDebugger.empty() ) {
mUIDebuggerList->runOnMainThread( [this] {
auto curConfig = mCurConfiguration;
mUIDebuggerList->getListBox()->setSelected( mCurDebugger );
mUIDebuggerConfList->getListBox()->setSelected( mCurConfiguration );
mUIDebuggerConfList->getListBox()->setSelected( curConfig );
} );
}
}
Expand Down Expand Up @@ -843,9 +852,11 @@ void DebuggerPlugin::updateSidePanelTab() {
}

if ( !empty ) {
if ( !mCurDebugger.empty() )
if ( !mCurDebugger.empty() ) {
auto curConfig = mCurConfiguration;
mUIDebuggerList->getListBox()->setSelected( mCurDebugger );
else
mCurConfiguration = std::move( curConfig );
} else
mUIDebuggerList->getListBox()->setSelected( 0L );
}

Expand Down Expand Up @@ -891,7 +902,7 @@ void DebuggerPlugin::updateDebuggerConfigurationList() {

std::string curConfig( mCurConfiguration );
mUIDebuggerConfList->getListBox()->clear();
mCurConfiguration = curConfig;
mCurConfiguration = std::move( curConfig );

std::string debuggerSelected = mUIDebuggerList->getListBox()->getItemSelectedText().toUtf8();

Expand Down
14 changes: 12 additions & 2 deletions src/tools/ecode/plugins/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../filesystemlistener.hpp"
#include "plugin.hpp"
#include <eepp/system/filesystem.hpp>
#include <eepp/system/md5.hpp>
#include <eepp/ui/uicheckbox.hpp>
#include <eepp/ui/uitableview.hpp>
#include <eepp/ui/uiwidgetcreator.hpp>
Expand All @@ -11,10 +12,11 @@ using json = nlohmann::json;
namespace ecode {

PluginManager::PluginManager( const std::string& resourcesPath, const std::string& pluginsPath,
std::shared_ptr<ThreadPool> pool, const OnLoadFileCb& loadFileCb,
PluginContextProvider* context ) :
const std::string& configPath, std::shared_ptr<ThreadPool> pool,
const OnLoadFileCb& loadFileCb, PluginContextProvider* context ) :
mResourcesPath( resourcesPath ),
mPluginsPath( pluginsPath ),
mConfigPath( configPath ),
mThreadPool( pool ),
mPluginContext( context ),
mLoadFileFn( loadFileCb ) {}
Expand Down Expand Up @@ -262,6 +264,14 @@ void PluginManager::setPluginReloadEnabled( bool pluginReloadEnabled ) {

void PluginManager::subscribeMessages(
Plugin* plugin, std::function<PluginRequestHandle( const PluginMessage& )> cb ) {
if ( plugin && !mWorkspaceFolder.empty() ) {
std::string projectsPath( mConfigPath + "projects" + FileSystem::getOSSlash() );
MD5::Result hash = MD5::fromString( mWorkspaceFolder );
std::string projectPluginsStatePath( projectsPath + "plugins_state" +
FileSystem::getOSSlash() + hash.toHexString() +
FileSystem::getOSSlash() );
plugin->onLoadProject( mWorkspaceFolder, projectPluginsStatePath );
}
subscribeMessages( plugin->getId(), cb );
}

Expand Down
2 changes: 2 additions & 0 deletions src/tools/ecode/plugins/pluginmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class PluginManager {
using OnLoadFileCb = std::function<void( const std::string&, const OnFileLoadedCb& )>;

PluginManager( const std::string& resourcesPath, const std::string& pluginsPath,
const std::string& configPath,
std::shared_ptr<ThreadPool> pool, const OnLoadFileCb& loadFileCb,
PluginContextProvider* context );

Expand Down Expand Up @@ -373,6 +374,7 @@ class PluginManager {
friend class App;
std::string mResourcesPath;
std::string mPluginsPath;
std::string mConfigPath;
std::string mWorkspaceFolder;
std::map<std::string, Plugin*> mPlugins;
std::map<std::string, bool> mPluginsEnabled;
Expand Down

0 comments on commit 0e5337d

Please sign in to comment.