From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 20 Sep 2012 23:12:51 +0000 (+0000)
Subject: Fix wxPluginLibrary wxClassInfo pointers initialization.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7cc3d0e00416303dc9c8696382a5eb571dd37ba0

Fix wxPluginLibrary wxClassInfo pointers initialization.

The values of m_ourFirst and m_ourLast were inversed in wxPluginLibrary ctor.
Fix this and explain in a comment that "first" and "last" here refer to the
order in the linked list and not the chronological order.

Closes #14483.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/common/dynload.cpp b/src/common/dynload.cpp
index 4714c64802..c2f1585adc 100644
--- a/src/common/dynload.cpp
+++ b/src/common/dynload.cpp
@@ -79,20 +79,21 @@ wxPluginLibrary::wxPluginLibrary(const wxString &libname, int flags)
     const wxClassInfo* const oldFirst = wxClassInfo::GetFirst();
     Load( libname, flags );
 
-    // It is simple to know what is the last object we registered, it's just
-    // the new head of the wxClassInfo list:
-    m_ourLast = wxClassInfo::GetFirst();
+    // It is simple to know what is the first object in the linked list of
+    // wxClassInfo that we registered (it's also the last one chronologically),
+    // it's just the new head of the wxClassInfo list:
+    m_ourFirst = wxClassInfo::GetFirst();
 
     // But to find the first wxClassInfo created by this library we need to
     // iterate until we get to the previous head as we don't have the links in
     // the backwards direction:
-    if ( m_ourLast != oldFirst )
+    if ( m_ourFirst != oldFirst )
     {
-        for ( const wxClassInfo* info = m_ourLast; ; info = info->GetNext() )
+        for ( const wxClassInfo* info = m_ourFirst; ; info = info->GetNext() )
         {
             if ( info->GetNext() == oldFirst )
             {
-                m_ourFirst = info;
+                m_ourLast = info;
                 break;
             }
         }