mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Fix debugger plugin reload.
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -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" );
|
||||
@@ -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 ) {
|
||||
@@ -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 );
|
||||
} );
|
||||
}
|
||||
}
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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 ) {}
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user