Skip to content

Commit

Permalink
#5200: Migrate a few onRadiantShutdown() to onMainFrameShuttingDown().
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Aug 28, 2020
1 parent fe4ad33 commit 0d59cc8
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 45 deletions.
10 changes: 5 additions & 5 deletions radiant/textool/TexTool.cpp
Expand Up @@ -173,7 +173,7 @@ void TexTool::gridDown() {
}
}

void TexTool::onRadiantShutdown()
void TexTool::onMainFrameShuttingDown()
{
rMessage() << "TexTool shutting down." << std::endl;

Expand All @@ -185,7 +185,7 @@ void TexTool::onRadiantShutdown()
Hide();
}

// Destroy the window (after it has been disconnected from the Eventmanager)
// Destroy the window
SendDestroyEvent();
InstancePtr().reset();
}
Expand All @@ -199,9 +199,9 @@ TexTool& TexTool::Instance()
// Not yet instantiated, do it now
instancePtr.reset(new TexTool);

// Register this instance with GlobalRadiant() at once
GlobalRadiant().signal_radiantShutdown().connect(
sigc::mem_fun(*instancePtr, &TexTool::onRadiantShutdown)
// Wire up the pre-destruction cleanup code
GlobalMainFrame().signal_MainFrameShuttingDown().connect(
sigc::mem_fun(*instancePtr, &TexTool::onMainFrameShuttingDown)
);
}

Expand Down
7 changes: 4 additions & 3 deletions radiant/textool/TexTool.h
Expand Up @@ -202,10 +202,11 @@ class TexTool :
public:
TexTool();

/** greebo: Some sort of "soft" destructor that de-registers
* this class from the SelectionSystem, saves the window state, etc.
/**
* greebo: Shutdown listeners de-registering from
* the SelectionSystem, saving the window state, etc.
*/
void onRadiantShutdown();
void onMainFrameShuttingDown();

/** greebo: This is the static accessor method containing
* the static instance of the TexTool class. Use this to access
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/aas/AasControlDialog.cpp
Expand Up @@ -187,7 +187,7 @@ void AasControlDialog::onMainFrameShuttingDown()
Hide();
}

// Destroy the window (after it has been disconnected from the Eventmanager)
// Destroy the window
SendDestroyEvent();

// Final step: clear the instance pointer
Expand Down
10 changes: 5 additions & 5 deletions radiant/ui/einspector/SkinChooser.cpp
Expand Up @@ -47,9 +47,9 @@ SkinChooser& SkinChooser::Instance()
// Not yet instantiated, do it now
instancePtr.reset(new SkinChooser);

// Register this instance with GlobalRadiant() at once
GlobalRadiant().signal_radiantShutdown().connect(
sigc::mem_fun(*instancePtr, &SkinChooser::onRadiantShutdown)
// Pre-destruction cleanup
GlobalMainFrame().signal_MainFrameShuttingDown().connect(
sigc::mem_fun(*instancePtr, &SkinChooser::onMainFrameShuttingDown)
);
}

Expand Down Expand Up @@ -288,13 +288,13 @@ std::string SkinChooser::chooseSkin(const std::string& model,
return Instance()._lastSkin;
}

void SkinChooser::onRadiantShutdown()
void SkinChooser::onMainFrameShuttingDown()
{
rMessage() << "SkinChooser shutting down." << std::endl;

_preview.reset();

// Destroy the window (after it has been disconnected from the Eventmanager)
// Destroy the window
SendDestroyEvent();
InstancePtr().reset();
}
Expand Down
5 changes: 1 addition & 4 deletions radiant/ui/einspector/SkinChooser.h
Expand Up @@ -65,9 +65,6 @@ class SkinChooser :
// Widget creation functions
void populateWindow();

// Show the dialog and block until selection is made
std::string showAndBlock(const std::string& model, const std::string& prev);

// Populate the tree with skins
void populateSkins();

Expand All @@ -85,9 +82,9 @@ class SkinChooser :
void setSelectedSkin(const std::string& skin);

void handleSelectionChange();
void onMainFrameShuttingDown();

public:
void onRadiantShutdown();

// Override Dialogbase
int ShowModal();
Expand Down
8 changes: 4 additions & 4 deletions radiant/ui/entitychooser/EntityClassChooser.cpp
Expand Up @@ -176,9 +176,9 @@ EntityClassChooser& EntityClassChooser::Instance()
// Not yet instantiated, do it now
instancePtr.reset(new EntityClassChooser);

// Register this instance with GlobalRadiant() at once
GlobalRadiant().signal_radiantShutdown().connect(
sigc::mem_fun(*instancePtr, &EntityClassChooser::onRadiantShutdown)
// Pre-destruction cleanup
GlobalMainFrame().signal_MainFrameShuttingDown().connect(
sigc::mem_fun(*instancePtr, &EntityClassChooser::onMainFrameShuttingDown)
);
}

Expand All @@ -191,7 +191,7 @@ EntityClassChooserPtr& EntityClassChooser::InstancePtr()
return _instancePtr;
}

void EntityClassChooser::onRadiantShutdown()
void EntityClassChooser::onMainFrameShuttingDown()
{
rMessage() << "EntityClassChooser shutting down." << std::endl;

Expand Down
7 changes: 3 additions & 4 deletions radiant/ui/entitychooser/EntityClassChooser.h
Expand Up @@ -67,7 +67,6 @@ class EntityClassChooser :
EntityClassChooser();

void setTreeViewModel();
void getEntityClassesFromLoader();
void loadEntityClasses();

// Widget construction helpers
Expand All @@ -86,6 +85,8 @@ class EntityClassChooser :
void onDeleteEvent(wxCloseEvent& ev);
void onTreeStorePopulationFinished(wxutil::TreeModel::PopulationFinishedEvent& ev);

void onMainFrameShuttingDown();

// This is where the static shared_ptr of the singleton instance is held.
static EntityClassChooserPtr& InstancePtr();

Expand All @@ -99,7 +100,7 @@ class EntityClassChooser :
// Sets the tree selection to the given entity class
const std::string& getSelectedEntityClass() const;

virtual int ShowModal();
int ShowModal() override;

/**
* Convenience function:
Expand All @@ -108,8 +109,6 @@ class EntityClassChooser :
* selection is made, and empty string will be returned.
*/
static std::string chooseEntityClass(const std::string& preselectEclass = std::string());

void onRadiantShutdown();
};

} // namespace ui
12 changes: 6 additions & 6 deletions radiant/ui/entitylist/EntityList.cpp
Expand Up @@ -213,14 +213,14 @@ void EntityList::toggle(const cmd::ArgumentList& args)
Instance().ToggleVisibility();
}

void EntityList::onRadiantShutdown()
void EntityList::onMainFrameShuttingDown()
{
if (IsShownOnScreen())
{
Hide();
}

// Destroy the window (after it has been disconnected from the Eventmanager)
// Destroy the window
SendDestroyEvent();
InstancePtr().reset();
}
Expand All @@ -236,11 +236,11 @@ EntityList& EntityList::Instance()
if (InstancePtr() == NULL)
{
// Not yet instantiated, do it now
InstancePtr() = EntityListPtr(new EntityList);
InstancePtr().reset(new EntityList);

// Register this instance with GlobalRadiant() at once
GlobalRadiant().signal_radiantShutdown().connect(
sigc::mem_fun(*InstancePtr(), &EntityList::onRadiantShutdown)
// Pre-destruction cleanup
GlobalMainFrame().signal_MainFrameShuttingDown().connect(
sigc::mem_fun(*InstancePtr(), &EntityList::onMainFrameShuttingDown)
);
}

Expand Down
13 changes: 7 additions & 6 deletions radiant/ui/entitylist/EntityList.h
Expand Up @@ -92,14 +92,15 @@ class EntityList :
void _preHide();
void _preShow();

/**
* greebo: Shuts down this dialog, safely disconnects it
* from the SelectionSystem.
* Saves the window information to the Registry.
*/
void onMainFrameShuttingDown();

public:
~EntityList();

/** greebo: Shuts down this dialog, safely disconnects it
* from the EventManager and the SelectionSystem.
* Saves the window information to the Registry.
*/
void onRadiantShutdown();

/** greebo: Toggles the window (command target).
*/
Expand Down
10 changes: 5 additions & 5 deletions radiant/ui/layers/LayerControlDialog.cpp
Expand Up @@ -224,7 +224,7 @@ void LayerControlDialog::onMainFrameConstructed()
}
}

void LayerControlDialog::onRadiantShutdown()
void LayerControlDialog::onMainFrameShuttingDown()
{
rMessage() << "LayerControlDialog shutting down." << std::endl;

Expand All @@ -237,7 +237,7 @@ void LayerControlDialog::onRadiantShutdown()
Hide();
}

// Destroy the window (after it has been disconnected from the Eventmanager)
// Destroy the window
SendDestroyEvent();

// Final step: clear the instance pointer
Expand All @@ -259,9 +259,9 @@ LayerControlDialog& LayerControlDialog::Instance()
// Not yet instantiated, do it now
instancePtr.reset(new LayerControlDialog);

// Register this instance with GlobalRadiant() at once
GlobalRadiant().signal_radiantShutdown().connect(
sigc::mem_fun(*instancePtr, &LayerControlDialog::onRadiantShutdown));
// Pre-destruction cleanup
GlobalMainFrame().signal_MainFrameShuttingDown().connect(
sigc::mem_fun(*instancePtr, &LayerControlDialog::onMainFrameShuttingDown));
}

return *instancePtr;
Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/layers/LayerControlDialog.h
Expand Up @@ -45,8 +45,6 @@ class LayerControlDialog :
public:
LayerControlDialog();

void onRadiantShutdown();

// Re-populates the window
void refresh();

Expand All @@ -64,6 +62,8 @@ class LayerControlDialog :
private:
static LayerControlDialogPtr& InstancePtr();

void onMainFrameShuttingDown();

// TransientWindow events
void _preShow() override;
void _postHide() override;
Expand Down

0 comments on commit 0d59cc8

Please sign in to comment.