diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp index 83edd99aa7..cda470510b 100644 --- a/src/blitter/factory.hpp +++ b/src/blitter/factory.hpp @@ -94,6 +94,24 @@ public: * @post Sets the blitter so GetCurrentBlitter() returns it too. */ static Blitter *SelectBlitter(const char *name) + { + BlitterFactory *b = GetBlitterFactory(name); + if (b == NULL) return NULL; + + Blitter *newb = b->CreateInstance(); + delete *GetActiveBlitter(); + *GetActiveBlitter() = newb; + + DEBUG(driver, 1, "Successfully %s blitter '%s'", StrEmpty(name) ? "probed" : "loaded", newb->GetName()); + return newb; + } + + /** + * Get the blitter factory with the given name. + * @param name the blitter factory to select. + * @return The blitter factory, or NULL when there isn't one with the wanted name. + */ + static BlitterFactory *GetBlitterFactory(const char *name) { #if defined(DEDICATED) const char *default_blitter = "null"; @@ -117,12 +135,7 @@ public: for (; it != GetBlitters().end(); it++) { BlitterFactory *b = (*it).second; if (strcasecmp(bname, b->name) == 0) { - Blitter *newb = b->CreateInstance(); - delete *GetActiveBlitter(); - *GetActiveBlitter() = newb; - - DEBUG(driver, 1, "Successfully %s blitter '%s'", StrEmpty(name) ? "probed" : "loaded", bname); - return newb; + return b; } } return NULL;