steinbergmedia/vstgui

VSTGUIEditorInterface::doIdleStuff is unused

sophiapoirier opened this issue · 2 comments

From what I can tell, VSTGUIEditorInterface::doIdleStuff is not called by anything within the VSTGUI codebase. Consequently I think it can be removed, and as a result of that, so can PluginGUIEditor::wait and getTicks and AEffGUIEditor::wait and getTicks. An advantage of removing those wait and getTicks methods is that then, on macOS, the legacy Carbon.framework dependency can be dropped.

diff --git a/vstgui/lib/cframe.h b/vstgui/lib/cframe.h
index 01309797..db6216e2 100644
--- a/vstgui/lib/cframe.h
+++ b/vstgui/lib/cframe.h
@@ -287,7 +287,6 @@ private:
 class VSTGUIEditorInterface
 {
 public:
-	virtual void doIdleStuff () {}
 	virtual int32_t getKnobMode () const { return -1; }
 	
 	virtual void beginEdit (int32_t index) {}
diff --git a/vstgui/plugin-bindings/aeffguieditor.cpp b/vstgui/plugin-bindings/aeffguieditor.cpp
index cf1507c1..5c5f8079 100644
--- a/vstgui/plugin-bindings/aeffguieditor.cpp
+++ b/vstgui/plugin-bindings/aeffguieditor.cpp
@@ -22,7 +22,6 @@
 #endif
 
 #if MAC
-#include <Carbon/Carbon.h>
 #include "getpluginbundle.h"
 
 namespace VSTGUI {
@@ -42,7 +41,6 @@ AEffGUIEditor::AEffGUIEditor (void* pEffect)
 {
 	((AudioEffect*)pEffect)->setEditor (this);
 	systemWindow = 0;
-	lLastTicks   = getTicks ();
 
 	#if WINDOWS
 	OleInitialize (nullptr);
@@ -139,66 +137,6 @@ bool AEffGUIEditor::onWheel (float distance)
 	return false;
 }
 
-//-----------------------------------------------------------------------------
-void AEffGUIEditor::wait (uint32_t ms)
-{
-	#if MAC
-	RunCurrentEventLoop (kEventDurationMillisecond * ms);
-	
-	#elif WINDOWS
-	Sleep (ms);
-
-	#endif
-}
-
-//-----------------------------------------------------------------------------
-uint32_t AEffGUIEditor::getTicks ()
-{
-	#if MAC
-	return (TickCount () * 1000) / 60;
-	
-	#elif WINDOWS
-	return (uint32_t)GetTickCount ();
-	
-	#endif
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-void AEffGUIEditor::doIdleStuff ()
-{
-	// get the current time
-	uint32_t currentTicks = getTicks ();
-
-	if (currentTicks < lLastTicks)
-	{
-		wait (kIdleRateMin);
-		currentTicks += kIdleRateMin;
-		if (currentTicks < lLastTicks - kIdleRate2)
-			return;
-	}
-
-	idle ();
-
-	#if WINDOWS
-	struct tagMSG windowsMessage;
-	if (PeekMessage (&windowsMessage, nullptr, WM_PAINT, WM_PAINT, PM_REMOVE))
-		DispatchMessage (&windowsMessage);
-
-	#endif
-
-	// save the next time
- 	lLastTicks = currentTicks + kIdleRate;
-
-	inIdleStuff = true;
-
-	if (effect)
-		effect->masterIdle ();
-
-	inIdleStuff = false;
-}
-
 //-----------------------------------------------------------------------------
 bool AEffGUIEditor::getRect (ERect **ppErect)
 {
diff --git a/vstgui/plugin-bindings/aeffguieditor.h b/vstgui/plugin-bindings/aeffguieditor.h
index 3d75852e..d407e4e9 100644
--- a/vstgui/plugin-bindings/aeffguieditor.h
+++ b/vstgui/plugin-bindings/aeffguieditor.h
@@ -39,15 +39,6 @@ public :
 	virtual bool onKeyUp (VstKeyCode& keyCode);
 	#endif
 
-	// wait (in ms)
-	void wait (uint32_t ms);
-
-	// get the current time (in ms)
-	uint32_t getTicks ();
-
-	// feedback to appli.
-	virtual void doIdleStuff ();
-
 	// get the effect attached to this editor
 	AudioEffect* getEffect () { return effect; }
 
@@ -72,7 +63,6 @@ protected:
 	ERect   rect;
 
 private:
-	uint32_t lLastTicks;
 	bool inIdleStuff;
 
 	static int32_t knobMode;
diff --git a/vstgui/plugin-bindings/plugguieditor.cpp b/vstgui/plugin-bindings/plugguieditor.cpp
index 3baed0da..b29aa0bf 100644
--- a/vstgui/plugin-bindings/plugguieditor.cpp
+++ b/vstgui/plugin-bindings/plugguieditor.cpp
@@ -16,7 +16,6 @@
 #endif
 
 #if MAC
-#include <Carbon/Carbon.h>
 #include "getpluginbundle.h"
 
 namespace VSTGUI {
@@ -38,7 +37,6 @@ PluginGUIEditor::PluginGUIEditor (void *pEffect)
 	: effect (pEffect)
 {
 	systemWindow = nullptr;
-	lLastTicks   = getTicks ();
 
 	#if WINDOWS
 	OleInitialize (nullptr);
@@ -88,71 +86,6 @@ int32_t PluginGUIEditor::setKnobMode (int32_t val)
 	return 1;
 }
 
-//-----------------------------------------------------------------------------
-void PluginGUIEditor::wait (uint32_t ms)
-{
-	#if MAC
-	RunCurrentEventLoop (kEventDurationMillisecond * ms);
-	
-	#elif WINDOWS
-	Sleep (ms);
-
-	#endif
-}
-
-//-----------------------------------------------------------------------------
-uint32_t PluginGUIEditor::getTicks ()
-{
-	#if MAC
-	return (TickCount () * 1000) / 60;
-	
-	#elif WINDOWS
-	return (uint32_t)GetTickCount ();
-	
-	#endif
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-void PluginGUIEditor::doIdleStuff ()
-{
-	// get the current time
-	uint32_t currentTicks = getTicks ();
-
-	// YG TEST idle ();
-	if (currentTicks < lLastTicks)
-	{
-		#if (MAC && TARGET_API_MAC_CARBON)
-		RunCurrentEventLoop (kEventDurationMillisecond * kIdleRateMin);
-		#else
-		wait (kIdleRateMin);
-		#endif
-		currentTicks += kIdleRateMin;
-		if (currentTicks < lLastTicks - kIdleRate2)
-			return;
-	}
-	idle (); // TEST
-
-	#if WINDOWS
-	struct tagMSG windowsMessage;
-	if (PeekMessage (&windowsMessage, nullptr, WM_PAINT, WM_PAINT, PM_REMOVE))
-		DispatchMessage (&windowsMessage);
-
-	#elif MAC && !__LP64__
-	EventRef event;
-	EventTypeSpec eventTypes[] = { {kEventClassWindow, kEventWindowUpdate}, {kEventClassWindow, kEventWindowDrawContent} };
-	if (ReceiveNextEvent (GetEventTypeCount (eventTypes), eventTypes, kEventDurationNoWait, true, &event) == noErr)
-	{
-		SendEventToEventTarget (event, GetEventDispatcherTarget ());
-		ReleaseEvent (event);
-	}
-	#endif
-
-	// save the next time
- 	lLastTicks = currentTicks + kIdleRate;
-}
-
 //-----------------------------------------------------------------------------
 bool PluginGUIEditor::getRect (ERect **ppErect)
 {
diff --git a/vstgui/plugin-bindings/plugguieditor.h b/vstgui/plugin-bindings/plugguieditor.h
index 7215057e..3ffea3ee 100644
--- a/vstgui/plugin-bindings/plugguieditor.h
+++ b/vstgui/plugin-bindings/plugguieditor.h
@@ -35,15 +35,6 @@ public :
 	virtual void idle ();
 	virtual void draw (ERect *pRect);
 
-	// wait (in ms)
-	void wait (uint32_t ms);
-
-	// get the current time (in ms)
-	uint32_t getTicks ();
-
-	// feedback to appli.
-	void doIdleStuff () override;
-
 	// get the effect attached to this editor
 	void *getEffect () { return effect; }
 
@@ -65,8 +56,6 @@ protected:
 	void* systemWindow;
 
 private:
-	uint32_t lLastTicks;
-
 	static int32_t knobMode;
 };
 

Removing a virtual method of an interface may break third party code. I can remove the carbon code from the files, no problem and leave empty methods for now.