Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash of reference pipes with the "--gui-only" option https://github.com/GrandOrgue/grandorgue/issues/2019 #2038

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed crash of reference pipes with the "--justgui" option https://github.com/GrandOrgue/grandorgue/issues/2019
- Fixed crash on attempt of loading an organ if it's files did not exist https://github.com/GrandOrgue/grandorgue/issues/1990
- Fixed the sequencer "Save file" button not lightening after inserting or deleting a combination https://github.com/GrandOrgue/grandorgue/issues/2024
- Fixed appearence, sizing and the scrollbar issues with the Stops window https://github.com/GrandOrgue/grandorgue/issues/1961
Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ model/GOOrganModel.cpp
model/GOPipe.cpp
model/GORank.cpp
model/GOReferencePipe.cpp
model/GOReferencingObject.cpp
model/GOSoundingPipe.cpp
model/GOStop.cpp
model/GOSwitch.cpp
Expand Down
13 changes: 13 additions & 0 deletions src/grandorgue/model/GOEventHandlerList.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class GOControl;
class GOControlChangedHandler;
class GOEventHandler;
class GOMidiConfigurator;
class GOReferencingObject;
class GOSoundStateHandler;
class GOSaveableObject;

Expand Down Expand Up @@ -57,6 +58,7 @@ class GOEventHandlerList {
};

UPVector<GOCacheObject> m_CacheObjects;
UPVector<GOReferencingObject> m_ReferencingObjects;
UPVector<GOCombinationButtonSet> m_CombinationButtonSets;
UPVector<GOControlChangedHandler> m_ControlChangedHandlers;
UPVector<GOMidiConfigurator> m_MidiConfigurators;
Expand All @@ -68,6 +70,9 @@ class GOEventHandlerList {
const std::vector<GOCacheObject *> &GetCacheObjects() const {
return m_CacheObjects.AsVector();
}
const std::vector<GOReferencingObject *> &GetReferencingObjects() const {
return m_ReferencingObjects.AsVector();
}
const std::vector<GOCombinationButtonSet *> &GetCombinationButtonSets()
const {
return m_CombinationButtonSets.AsVector();
Expand All @@ -87,6 +92,14 @@ class GOEventHandlerList {

void RegisterCacheObject(GOCacheObject *obj) { m_CacheObjects.Add(obj); }

void RegisterReferencingObject(GOReferencingObject *pObj) {
m_ReferencingObjects.Add(pObj);
}

void UnRegisterReferencingObject(GOReferencingObject *pObj) {
m_ReferencingObjects.Remove(pObj);
}

void RegisterCombinationButtonSet(GOCombinationButtonSet *obj) {
m_CombinationButtonSets.Add(obj);
}
Expand Down
4 changes: 4 additions & 0 deletions src/grandorgue/model/GOOrganModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "GOEnclosure.h"
#include "GOManual.h"
#include "GORank.h"
#include "GOReferencingObject.h"
#include "GOSwitch.h"
#include "GOTremulant.h"
#include "GOWindchest.h"
Expand Down Expand Up @@ -169,6 +170,9 @@ void GOOrganModel::Load(GOConfigReader &cfg) {
for (unsigned i = 0; i < m_tremulants.size(); i++)
m_tremulants[i]->SetElementID(
GetRecorderElementID(wxString::Format(wxT("T%d"), i)));

for (GOReferencingObject *pObj : GetReferencingObjects())
pObj->ResolveReferences();
}

void GOOrganModel::LoadCmbButtons(GOConfigReader &cfg) {
Expand Down
7 changes: 2 additions & 5 deletions src/grandorgue/model/GOReferencePipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <wx/intl.h>
#include <wx/tokenzr.h>

#include "config/GOConfigReader.h"

#include "GOManual.h"
#include "GOOrganModel.h"
#include "GORank.h"
Expand All @@ -20,21 +18,20 @@
GOReferencePipe::GOReferencePipe(
GOOrganModel *model, GORank *rank, unsigned midi_key_number)
: GOPipe(model, rank, midi_key_number),
GOReferencingObject(*model),
m_model(model),
m_Reference(NULL),
m_ReferenceID(0),
m_Filename() {}

void GOReferencePipe::Load(
GOConfigReader &cfg, const wxString &group, const wxString &prefix) {
SetGroupAndPrefix(group, prefix);
m_model->RegisterCacheObject(this);
m_Filename = cfg.ReadStringTrim(ODFSetting, group, prefix);
if (!m_Filename.StartsWith(wxT("REF:")))
throw(wxString) _("ReferencePipe without Reference");
}

void GOReferencePipe::Initialize() {
void GOReferencePipe::OnResolvingReferences() {
if (!m_Filename.StartsWith(wxT("REF:")))
throw(wxString) _("ReferencePipe without Reference");

Expand Down
10 changes: 3 additions & 7 deletions src/grandorgue/model/GOReferencePipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,18 @@

#include "GOCacheObject.h"
#include "GOPipe.h"
#include "GOReferencingObject.h"

class GOOrganModel;

class GOReferencePipe : public GOPipe, private GOCacheObject {
class GOReferencePipe : public GOPipe, public GOReferencingObject {
private:
GOOrganModel *m_model;
GOPipe *m_Reference;
unsigned m_ReferenceID;
wxString m_Filename;

void Initialize() override;
void LoadData(const GOFileStore &fileStore, GOMemoryPool &pool) override {}
bool LoadCache(GOMemoryPool &pool, GOCache &cache) override { return true; }
bool SaveCache(GOCacheWriter &cache) const override { return true; }
void UpdateHash(GOHash &hash) const override {}
const wxString &GetLoadTitle() const override { return m_Filename; }
void OnResolvingReferences() override;

void VelocityChanged(unsigned velocity, unsigned old_velocity) override;

Expand Down
26 changes: 26 additions & 0 deletions src/grandorgue/model/GOReferencingObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#include "GOReferencingObject.h"

#include "GOEventHandlerList.h"

GOReferencingObject::GOReferencingObject(GOEventHandlerList &handlerList)
: r_HandlerList(handlerList) {
r_HandlerList.RegisterReferencingObject(this);
}

GOReferencingObject::~GOReferencingObject() {
r_HandlerList.UnRegisterReferencingObject(this);
}

void GOReferencingObject::ResolveReferences() {
if (!m_HasBeenResolved) {
OnResolvingReferences();
m_HasBeenResolved = true;
}
}
28 changes: 28 additions & 0 deletions src/grandorgue/model/GOReferencingObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/

#ifndef GOREFERENCINGOBJECT_H
#define GOREFERENCINGOBJECT_H

class GOEventHandlerList;

class GOReferencingObject {
private:
GOEventHandlerList &r_HandlerList;
bool m_HasBeenResolved = false;

protected:
virtual void OnResolvingReferences() {}

public:
GOReferencingObject(GOEventHandlerList &handlerList);
virtual ~GOReferencingObject();

void ResolveReferences();
};

#endif /* GOREFERENCINGOBJECT_H */
4 changes: 1 addition & 3 deletions src/grandorgue/model/GOTremulant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ void GOTremulant::OnDrawstopStateChanged(bool on) {
m_PlaybackHandle = pSoundEngine ? pSoundEngine->StartTremulantSample(
m_TremProvider, m_TremulantN, m_LastStop)
: nullptr;
on = (m_PlaybackHandle != nullptr);
} else {
assert(m_PlaybackHandle);
} else if (m_PlaybackHandle) {
m_LastStop = pSoundEngine
? pSoundEngine->StopSample(m_TremProvider, m_PlaybackHandle)
: 0;
Expand Down
Loading