Browse Source

Fixed issue #1215.

Branimir Karadžić 8 years ago
parent
commit
578ed35243
3 changed files with 35 additions and 12 deletions
  1. 24 0
      examples/common/entry/entry.cpp
  2. 0 4
      examples/common/entry/entry.h
  3. 11 8
      examples/common/example-glue.cpp

+ 24 - 0
examples/common/entry/entry.cpp

@@ -460,6 +460,30 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		s_numApps++;
 	}
 
+	AppI::~AppI()
+	{
+		for (AppI* prev = NULL, *app = s_apps, *next = app->getNext()
+			; NULL != app
+			; prev = app, app = next, next = app->getNext() )
+		{
+			if (app == this)
+			{
+				if (NULL != prev)
+				{
+					prev->m_next = next;
+				}
+				else
+				{
+					s_apps = next;
+				}
+
+				--s_numApps;
+
+				break;
+			}
+		}
+	}
+
 	const char* AppI::getName() const
 	{
 		return m_name;

+ 0 - 4
examples/common/entry/entry.h

@@ -310,10 +310,6 @@ namespace entry
 		const char* m_description;
 	};
 
-	inline AppI::~AppI()
-	{
-	}
-
 	///
 	AppI* getFirstApp();
 

+ 11 - 8
examples/common/example-glue.cpp

@@ -77,16 +77,19 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
 			cmdExec("app restart");
 		}
 
-		ImGui::SameLine();
-		if (ImGui::Button(ICON_KI_PREVIOUS " Prev") )
+		if (1 < entry::getNumApps() )
 		{
-			cmdExec("app restart prev");
-		}
+			ImGui::SameLine();
+			if (ImGui::Button(ICON_KI_PREVIOUS " Prev") )
+			{
+				cmdExec("app restart prev");
+			}
 
-		ImGui::SameLine();
-		if (ImGui::Button(ICON_KI_NEXT " Next") )
-		{
-			cmdExec("app restart next");
+			ImGui::SameLine();
+			if (ImGui::Button(ICON_KI_NEXT " Next") )
+			{
+				cmdExec("app restart next");
+			}
 		}
 
 		ImGui::SameLine();